Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Llama3 instruct prompt template missing BOS token

Aperta Adatta ai principianti
#1,537 6 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
70/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Stack tecnologico
python

Direzione di ricerca

Il problema si trova nel template del prompt di chat di Llama3. Esamina il file llama_cpp/llama_chat_format.py e la funzione format_llama3. Confronta l'output tra le versioni 0.2.77 e 0.2.78 per vedere il token BOS mancante, '<|begin_of_text|>'. Aggiungi nuovamente il token alla costruzione del prompt. Esegui il test importando la funzione e verificando che l'output corrisponda al formato previsto dalla documentazione di Meta.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Prerequisites

Please answer the following questions for yourself before submitting an issue.

  • I am running the latest code. Development is very rapid so there are no tagged versions as of now.
  • I carefully followed the README.md.
  • I searched using keywords relevant to my issue to make sure that I am creating a new issue that is not already open (or closed).
  • I reviewed the Discussions, and have a new bug or useful enhancement to share.

Expected Behavior

Llama3 models using the prompt template in llama-cpp-python>0.2.77 are missing the BOS token and then the model quality is degraded.

For example, the Meta doc on Llama 3 has prompt template examples here: https://llama.meta.com/docs/model-cards-and-prompt-formats/meta-llama-3/

Current Behavior

Result of an empty format_llama3({}) after from llama_cpp.llama_chat_format import format_llama3:

0.2.78:

ChatFormatterResponse(prompt='<|start_header_id|>assistant<|end_header_id|>\n\n', stop='<|eot_id|>', stopping_criteria=None, added_special=False)

0.2.77:

ChatFormatterResponse(prompt='<|begin_of_text|><|start_header_id|>assistant<|end_header_id|>\n\n', stop='<|eot_id|>', stopping_criteria=None)

Environment and Context

  • Operating System, e.g. for Linux:
22.6.0 Darwin Kernel Version 22.6.0: Mon Apr 22 20:49:37 PDT 2024; root:xnu-8796.141.3.705.2~1/RELEASE_ARM64_T6000 arm64
  • SDK version, e.g. for Linux:
Python 3.10.13
GNU Make 3.81
$ g++ --version

Failure Information (for bugs)

Please help provide information about the failure if this is a bug. If it is not a bug, please remove the rest of this template.

Steps to Reproduce

Install versions 0.2.77 and 0.2.78 and test anything with a Llama 3 model and llm.create_chat_completion. In addition, import the templates and check the difference.

I am using https://huggingface.co/bartowski/Meta-Llama-3-8B-Instruct-GGUF/tree/main as a model for testing, particularly the Q5_K_M quantization, but this should affect all models.

Lingua principale
Python
Stelle
10.6k
Fork
1.5k
Merge medio
6h 43m
PR unite (30g)
2

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di abetlen/llama-cpp-python

Tutte le issue di abetlen/llama-cpp-python

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.