my fine tuned llama model does not greets back. #12272
Replies: 2 comments 4 replies
-
Hey @Areej17-01! Great to see you back around these parts. Ready for another adventure in code? 🚀 Based on the code you've shared, it seems like the Llama model is not correctly interpreting the system prompt. The system prompt is designed to guide the model's behavior, but it's not a strict rule that the model will always follow. The model might still generate unexpected responses if it doesn't understand the prompt or if the prompt is not specific enough. To address this issue, you could try refining the system prompt to make it more explicit. For example, you could specify that the model should always respond with a greeting when it receives a greeting. Here's an example of how you might modify the system prompt: system_prompt = """[INST] <>
You are a helpful, respectful, and honest MULTILINGUAL assistant. Always answer as helpfully as possible, while being safe. Your answers should not include any harmful, unethical, racist, sexist, toxic, dangerous, or illegal content. Please ensure that your responses are socially unbiased and positive in nature.
If the user greets you with a simple "hello," "hi," "hey," or similar greeting, regardless of the number of letters repeated or the informality of the greeting, respond with a friendly greeting in return. Do not provide any other information unless specifically asked by the user.
If a question does not make any sense, or is not factually coherent, explain why instead of answering something incorrect. If you don't know the answer to a question, please don't share false information.
Your goal is to provide answers relating to the documents and context provided about 'context'.
[/INST] <>
""" In this modified prompt, the instruction to respond with a greeting when greeted is more explicit, which might help guide the model's behavior more effectively. If refining the system prompt doesn't resolve the issue, you might need to implement a preprocessing step to handle greetings before they are passed to the model. This could involve identifying greetings in the user's input and replacing them with a standardized response, as suggested in the previous response. Here's an example of how you might implement such a preprocessing step: import re
def preprocess_input(input_text):
# Define a regular expression pattern for greetings
greetings_pattern = r"\b(hi|hello|hey|greetings)\b"
# Check if the input text matches the greetings pattern
if re.search(greetings_pattern, input_text, re.IGNORECASE):
# Standardize or replace the greeting with a predefined response or action
standardized_response = "Hello! How can I assist you today?"
return standardized_response
else:
# If no greeting is detected, return the original input text
return input_text
# Example usage
user_input = "hi"
processed_input = preprocess_input(user_input)
print(processed_input) # Outputs: "Hello! How can I assist you today?" In this example, the I hope this helps! If you have any further questions or issues, please don't hesitate to ask. Sources
|
Beta Was this translation helpful? Give feedback.
-
Hello @dosu-bot. I have a problem in my chatbot. Actually we are using Llama3.1 as an LLM in our RAG Application but the issue is it is not picking our prompting our prompt for retrieving response. And if the query is "Hi", "Hello", What's up?", it is not getting prompt from template in which we mention it "Hi! How I can assist you today?"and insteda of this it is replying us with the previous queries response as in the session context. Please resolve my issue. @dosu-bot. below is my code: qa_prompt = """ Task:Respond to the user query using the provided context, incorporating inline citations in the format [source_id] only when the <source_id> tag is explicitly provided in the context. Guidelines:
Example of Citation:If the user asks about a specific topic and the information is found in "whitepaper.pdf" with a provided <source_id>, the response should include the citation like so:
Output:Provide a clear and direct response to the user's query, including inline citations in the format [source_id] only when the <source_id> tag is present in the context. {retrieved_chunks}<user_query> Below is the pipeline of RAG for answer retrieval: import logging class StreamPipeline:
|
Beta Was this translation helpful? Give feedback.
-
HI, I am new to RAG and LLMs. I am using the Llama model by TheBloke/Llama-2-7B-Chat-GGUF for RAG, and it performs well in information retrieval. I am utilizing the LlamaIndex query engine. However, whenever the user says "hi," "hello," or any other greeting, it hallucinates and replies with a self-fabricated answer. Is there a way to resolve this without creating separate responses for greetings? Any help would be appreciated. Thanks!
Code:
Beta Was this translation helpful? Give feedback.
All reactions