Repetition Issues with Llamacpp

#2
by monoboard - opened

Hey everyone, I'm currently working with seallm-7b-v2.5.Q4_K_M.gguf for RAG. Here are the settings I'm using:

from llama_index.llms.llama_cpp import LlamaCPP

model_url = "https://huggingface.co/SeaLLMs/SeaLLM-7B-v2.5-GGUF/resolve/main/seallm-7b-v2.5.Q4_K_M.gguf"

llm = LlamaCPP(
    model_url=model_url,
    temperature=0.1,
    max_new_tokens=1024,
    context_window=8192,
    generate_kwargs={},
    model_kwargs={"n_gpu_layers": 64, "repeat_penalty": 1},
    verbose=True
)

with this prompt

# SeaLLM 7b-v2.5
from llama_index.core import PromptTemplate, get_response_synthesizer

prompt="""
<bos><|im_start|>system
You are a helpful assistant. You will only answer based on provided document if relevant to users question.<eos>
<|im_start|>user
คุณเป็นแชทบอทของรัฐบาลที่ออกแบบมาเพื่อช่วยเหลือผู้ใช้ในการตอบคำถามตามเอกสาร "รวมกฎหมายที่ดินและสิ่งปลูกสร้าง" ให้ปฏิบัติตามแนวทางการให้เหตุผลแบบ Chain-Of-Thought ดังนี้
1) ตอบกลับเป็นภาษาไทย 
2) ใช้บริบทที่ให้มาจากเอกสาร "รวมกฎหมายที่ดินและสิ่งปลูกสร้าง" เพื่อนำมาใช้ตอบคำถามอย่างมีเหตุผล 
3) แบ่งปัญหาออกเป็นส่วนย่อยๆ หากจำเป็น และพิจารณาขั้นตอนดังต่อไปนี้ (provide step-by-step reasoning on how to answer the question): 
    ก) ระบุหัวข้อหลักหรือประเภทของคำถาม (เช่น การยกเว้นภาษี คำนิยามตามกฎหมาย การใช้ประโยชน์ที่ดิน) 
    ข) ค้นหาส่วนหรือข้อความในเอกสารที่อาจมีคำตอบ 
    ค) สกัดข้อมูลที่เกี่ยวข้องจากส่วนที่ระบุ 
    ง) นำข้อมูลที่สกัดมาใช้กับคำถามที่ถามโดยเฉพาะ 
    จ) สร้างคำตอบตามเนื้อหาของเอกสาร 
4) ตอบคำถามแบบสั้นและกระชับ
5) หากไม่พบคำตอบในเอกสารหรือคำถามต้องการข้อมูลที่ไม่มี ให้ตอบว่า "ไม่รู้" 
คุณจะได้รับรายละเอียดใน รวมกฎหมายที่ดินและสิ่งปลูกสร้าง ตามคำถามของผู้ใช้ รวมกฎหมายที่ดินและสิ่งปลูกสร้าง ใน ''' ด้านล่าง
'''
รวมกฎหมายที่ดินและสิ่งปลูกสร้าง: {context_str}
'''
ห้ามใช้ข้อมูลใดๆ นอกเหนือ "รวมกฎหมายที่ดินและสิ่งปลูกสร้าง" ที่ให้ไว้
QUESTION: {query_str} <eos>
<|im_start|>assistant
ANSWER: """

text_qa_template = PromptTemplate(prompt)

Here is the response from the model

400 ต้น

ตามข้อมูลในเอกสาร "รวมกฎหมาย ที่ดินและสิ่งปลูกสร้าง" บุคคลธรรมดาจะได้รับยกเว้นภาษีสำหรับการประกอบการเกษตรกรรมหากปลูกพืชนานาชนิดตามขั้นต่ำกำหนดไว้ โดยในกรณีนี้คือปลูกกล้วยต้องไม่ต่ำกว่าจำนวนต้นตามตารางกำหนดไว้ ดังนั้น หากบุคคลธรรมดาเจ้าหน้าทีดินจำนวนสองไร่ ต้องปลูกกล้วยไม่ต่ำกว่าจำนวนต้นตามตารางกำหนด ไว้คือปลูกกล้วยไม่ต่ำกว่าจำนวนต้นตามตารางกำหนดไว้คือปลูกกล้วยไม่ต่ำกว่าจำนวนต้นตามตารางกำหนดไว้คือปลูกกล้วยไม่ต่ำกว่าจำนวนต้นตามตารางกำหนดไว้คือปลูกกล้วย ....

I'm facing an issue with repeated text "ไว้คือปลูกกล้วยไม่ต่ำกว่าจำนวนต้นตามตารางกำหนด" until the max token limit is reached. The issue doesn't occur with SeaLLM-7B-v2.q8_0.gguf Any suggestions or help would be greatly appreciated!

have you try repeat_penalty=1.0

have you try repeat_penalty=1.0

hi @saknarak , thank you for your response. I have already tried setting repeat_penalty=1.0 or repetition_penalty=1.0 in model_kwargs, but the repetition issue is still there.

Hi folk,

If you would like to validate the results with full precision models, you can visit float16.cloud. I have been supporting SeaLLM-7b-v2.5 since its inception.

In the upcoming month, I will provide a deployment tutorial with LLamacpp on my GitHub.

Feel free to ask me any questions.

Sign up or log in to comment