simonw / simonw/llm

How could LLM handle fill-in-the-middle?

Open
#227 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

design help wanted
Dominant language
Python
Stars
12.5k
Forks
998
Avg merge
3d 13h
Merged PRs (30d)
10

Description

LLM is currently designed mainly around chat prompts. But there are other forms of LLM interaction, in particular "fill-in-the-middle" as seen in GitHub Copilot.

https://huggingface.co/smallcloudai/Refact-1_6B-fim is an example of a model that supports this:

prompt = '''<fim_prefix>def print_hello_world():
    """<fim_suffix>
    print("Hello world!")<fim_middle>'''

Output from that:

<fim_prefix>def print_hello_world():
    """<fim_suffix>
    print("Hello world!")<fim_middle>Prints 'Hello world!'"""<|endoftext|>

Which, if you figure out how to construct it again, ends up like this:

def print_hello_world():
    """Prints 'Hello world!'"""
    print("Hello world!")

How could LLM support this? Would I need to design a new variant of the llm prompt command and model.prompt() method for this case?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the existing llm prompt command and model.prompt() method to understand how chat prompts are represented and sent. Compare that flow with the documented fill-in-the-middle prefix, suffix, and middle markers. Done means a defined interface and behavior for FIM interactions, including how the command and model API would expose them.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
ai, cli
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.