Skip to content

Prompt Strategies for Open-Source LLMs: EleutherAI's GPT-J and GPT-NeoX

Prompt Engineering

December 4, 2025

What Makes Open-Source LLM Prompts Different

Open-source LLM prompts don't work the same way as prompts you write for ChatGPT or Claude. Models like EleutherAI's GPT-J and GPT-NeoX were trained differently, have different defaults, and respond to different cues. If you treat them like a chat assistant, you'll get frustrating results. If you meet them where they are, they can be genuinely powerful tools.

This post walks through what GPT-J and GPT-NeoX actually are, how they process text, and what prompt strategies get the best results from each. We'll cover practical techniques you can apply right away, whether you're running these models locally or through an API endpoint.

GPT-J and GPT-NeoX: A Quick Orientation

Both models come from EleutherAI, a nonprofit research group that has made large language models freely available. That's significant because it means you can run these models on your own hardware, inspect the weights, and use them without sending data to a third-party service.

GPT-J-6B

GPT-J-6B has 6 billion parameters and was released in 2021. It's a text completion model trained on the Pile, a large open dataset assembled by EleutherAI from sources including books, web text, code repositories, and academic papers. At the time of release it was one of the most capable publicly available models.

The key thing to understand: GPT-J completes text. It doesn't follow instructions the way a fine-tuned chat model does. You give it a beginning, and it continues from there. That shapes every prompt decision you make.

GPT-NeoX-20B

GPT-NeoX-20B has 20 billion parameters and was released in 2022. Also trained on the Pile, it performs significantly better than GPT-J on tasks requiring reasoning, code generation, and longer coherent output. It uses a different architecture that includes rotary positional embeddings, which helps it handle longer sequences more gracefully.

Like GPT-J, it's a completion model at its base, though various fine-tuned versions have been released by the community that add instruction-following behavior.

Core Prompt Strategies for Open-Source LLM Prompts

Because these are completion models, the most important shift in mindset is this: your prompt is the beginning of a document, not a message to an assistant. Write the start of the kind of text you want, and the model will continue it.

Use Completion Framing Instead of Instructions

Instructional prompts like "Write a summary of the following article" often produce weaker results on base GPT-J and GPT-NeoX than framing the prompt as the start of a completed piece.

Instead of:

Write a summary of the following article: [article text]

Try:

The following is a concise summary of the article above:

The article discusses

That second version gives the model a clear pattern to continue. It knows it's writing a summary because that's what the document says it's doing. The model fills in the rest naturally.

Few-Shot Examples Are Your Best Tool

Few-shot prompting means including examples of the input-output pattern you want, right in the prompt. This works extremely well with GPT-J and GPT-NeoX because the models are good at recognizing and extending patterns.

Here's a basic structure:

  • Write two or three examples of the task, formatted consistently
  • Use the same separator between each example (a blank line, a dashed line, or a label like "Example 3:")
  • End with the input for your actual task, leaving the output blank for the model to complete

For example, if you want the model to extract keywords from text:

Text: The stock market fell sharply on concerns about inflation.
Keywords: stock market, inflation, economy

Text: Scientists have discovered a new species of deep-sea fish near hydrothermal vents.
Keywords: deep-sea fish, hydrothermal vents, marine biology

Text: The city council voted to approve a new public transit expansion plan.
Keywords:

The model recognizes the pattern immediately and completes accordingly. Three examples usually works well. More than five rarely adds much and starts to consume context window space you might need for the actual task.

Control Tone and Style Through Framing

GPT-J and GPT-NeoX have absorbed enormous amounts of text from many different registers: academic papers, forum posts, news articles, fiction, code comments. You can steer the style of output by framing your prompt to match that register.

If you want a formal explanation of a concept:

From a peer-reviewed overview of machine learning fundamentals:

Gradient descent is an optimization algorithm used to minimize a loss function by

If you want a casual explanation of the same concept:

From a beginner-friendly blog post about machine learning:

Gradient descent is basically how a model learns from its mistakes. Think of it as

The framing primes the model to continue in that voice. This is one of the most reliable style controls available without fine-tuning.

Set Temperature and Sampling Parameters Thoughtfully

These models are highly sensitive to generation parameters. If you have access to the API or are running the model yourself, these settings matter a lot.

  • Temperature controls randomness. A value of 0.7 to 0.9 works well for creative tasks. For factual completion or structured output, bring it down to 0.3 to 0.5.
  • Top-p (nucleus sampling) limits the token pool to the most probable candidates. A value around 0.9 works for most tasks.
  • Repetition penalty is especially useful with GPT-NeoX, which can sometimes loop back and repeat phrases. A value of 1.1 to 1.3 helps break that pattern.
  • Max new tokens should be set deliberately. These models don't know when to stop unless you give them a clear ending cue in the prompt or cap the output length.

Specific Techniques for GPT-J

GPT-J's smaller size makes it faster and cheaper to run, but it requires cleaner prompts to stay on task. A few approaches that work particularly well:

Keep the Prompt Tight

GPT-J has a context window of 2,048 tokens. Use them wisely. Long preambles that explain what you want in abstract terms eat into that space without adding much. Get to the actual content quickly. If you're using few-shot examples, keep each one short and representative rather than exhaustive.

Use a Clear Stop Signal

GPT-J will sometimes keep generating past the point where you want it to stop. If you're using an API, set a stop sequence: a string that tells the model (or the API) to halt generation. For structured outputs, something like a double newline or a label like "END" or "---" works well, as long as you include that pattern consistently in your examples.

Avoid Open-Ended Prompts for Factual Tasks

GPT-J can hallucinate confidently. It will make up names, dates, and citations if the prompt invites it to speculate. For anything where accuracy matters, structure your prompt so the model is filling in a narrow slot rather than generating freely. Ask it to extract, classify, or reformat rather than to recall or explain from memory.

Specific Techniques for GPT-NeoX

GPT-NeoX's larger size gives it noticeably better reasoning and coherence on longer tasks, but it also behaves differently from GPT-J in some important ways.

It Handles Multi-Step Tasks Better

You can ask GPT-NeoX to work through a problem in steps by prompting it to do so explicitly. Something like:

To answer this question, let's think through it step by step.

Question: If a train travels at 60 miles per hour and needs to cover 150 miles, how long will the journey take?

Step 1:

This chain-of-thought framing encourages the model to reason before arriving at an answer. It won't always succeed, but it succeeds more often with GPT-NeoX than with GPT-J, simply because the larger model has more capacity to maintain a logical thread across several steps.

Code Generation Works With Explicit Context

GPT-NeoX was trained on a substantial amount of code from the Pile dataset. It can generate useful code snippets when the prompt gives it clear context about language, purpose, and existing code structure.

A prompt structure that works well:

# Python 3.10
# Function to read a CSV file and return a list of dictionaries

import csv

def read_csv(filepath):

Starting the function signature yourself is often more reliable than asking the model to write an entire function from a description. The model continues from where you left off rather than making assumptions about structure.

Watch the Repetition Behavior

GPT-NeoX at higher temperatures can fall into repetition loops on longer generations. Set a repetition penalty in your generation config and test with shorter max token limits first. Extend the length once you're confident the prompt is producing coherent output at a shorter length.

Common Mistakes and How to Avoid Them

People new to base completion models make a few predictable errors. Here are the ones we see most often and what to do instead.

  • Writing prompts like messages. "Hey, can you help me write a product description?" won't work well. Start the product description yourself and let the model continue it.
  • Expecting the model to know when to stop. These models don't have an end-of-turn concept. Build a stop sequence into your setup or cap output length explicitly.
  • Using inconsistent formatting in few-shot examples. If your examples have different spacing, labeling, or punctuation, the model gets confused about the pattern. Be exact and consistent.
  • Running the same prompt once and concluding it doesn't work. There's randomness in generation. Run the same prompt several times. If it works on two of five runs, your prompt is on the right track. Adjust temperature or the prompt phrasing to tighten it.
  • Ignoring the training data character of the Pile. Both models know a lot about some domains and very little about others. They're strong on English-language web text, code, books, and academic writing. They're weaker on highly specialized or recent information.

Fine-Tuned Variants Worth Knowing

The community has released many fine-tuned versions of both GPT-J and GPT-NeoX that add instruction-following behavior. These sit between a raw completion model and a fully aligned chat assistant.

Some widely used variants include GPT-J-6B-Alpaca (fine-tuned on instruction data similar to Stanford Alpaca) and various NeoX-based models fine-tuned for coding or classification tasks. If you're finding raw completion prompting limiting for your use case, exploring a fine-tuned variant of the same base model is a logical next step before moving to a larger or proprietary model.

Fine-tuned models typically accept a specific prompt format that you need to follow. Read the model card before writing prompts, because using the wrong format with a fine-tuned model often produces noticeably worse output than the base model would have given on the same task.

Putting It Into Practice

The most useful thing you can do after reading this is pick one task you care about and test it systematically. Write three versions of the prompt: one that frames it as a document the model is continuing, one with two few-shot examples, and one with three. Run each version five times at the same temperature. Compare the results, adjust what isn't working, and iterate. That process builds intuition faster than any amount of reading about prompt engineering in the abstract.

If you'd like a second set of eyes on your prompt setup or want to understand how open-source models fit into a broader workflow, book your free first consultation with our team and we'll work through it with you.

More in Prompt Engineering

Mastering Zero-Shot Learning Through Effective Prompt Design

Mastering Zero-Shot Learning Through Effective Prompt Design

Zero-shot learning prompts are the foundation of effective AI tool use, but most people don't know how to write them well. This guide breaks down the structure, principles, and practical techniques you need to get consistently better results from AI.

Aug 23, 2026

How to Use Prompt Chaining for Complex LLM Tasks

How to Use Prompt Chaining for Complex LLM Tasks

Prompt chaining breaks complex AI tasks into a sequence of focused steps, each building on the last, so you get more accurate, controllable results than a single prompt can produce. This guide explains how to design, run, and eventually automate your own prompt chains.

Nov 14, 2025

Want this working in your business?

CLIENT SUCCESS SPOTLIGHT

A real business operating system. In production. With active tenants.

Club Central: Gymnastics of York