Struggling to Structure Multi-Faceted Prompts Without Issues Using LlamaSharp → llama.cpp → LLaMA-3.1 #15606
CharlieMunzer
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi all, I’ve been struggling for weeks with prompt formatting in my LlamaSharp → llama.cpp → LLaMA-3.1 pipeline. Despite multiple iterations, my chatbot still behaves inconsistently, and I’d really appreciate guidance.
My Setup:
LLM: LLaMA 3.1 8B Q5 (GGUF, instruction/chat-tuned variant)
Stack: LLamaSharp → llama.cpp → the GGUF model
Goal: A single combined prompt that includes:
Conversation history (previous user + assistant turns – stored in DB)
Application-level prompts (e.g., formatting guides, custom instructions for behavior)
System prompt(s) (role definitions, constraints)
User prompt(s) (current context, the current question or instruction)
The Prompt Pipeline:
I’m not sure how to prompt because I don’t know what the structure looks like as it travels from LLamaSharp to llama.cpp to the model.
Does my prompt change differently down in its travels to the LLM depending on if I make it 1 large prompt or many chart-histories messages in llamasharp.
I’m told the llama 3.1 LLM likes the prompt formatted with specific tags, but how do I view the format inputting across several chat-session history messages at the LLM level.
Is there a way to view or log the exact prompt text before it's sent to the model?
Are there established templates or best practices for LLaMA 3.1 in LLamaSharp—for example, how to layer system vs user vs history vs formatting cues?
Any pointers on handling long context safely, or debugging when the model ignores or misinterprets parts of the prompt?
The Chatbot Gets Confused Sometimes:
Sometimes it replies great and sometimes it gets in a mood. Maybe it’s not my prompt it is caused by running on a non-gpu machine with 64G memory. But, my token counts are way under that which are permitted. I reuse context and chat-session per user but clear out all history-messages upon reply completion and each time I get a request. My inference params are fairly rigid
When it gets in these moods it often does not respond properly as often as it should, sometimes repeating, sometime rambling, sometimes misunderstanding my prompt’s intent.
Example Prompt
History (both user and system in full-text, but not too many tokens worth)
a. System (History Example) User (Past): What is capital of France\n\nAssistant (Past): The capital of France is Paris. It's the city where many famous landmarks like the Eiffel Tower and Notre Dame Cathedral are located. Would you like to know more about the history of Paris or its cultural significance?\n\nSystem: The previous information is prior conversation history for context only. Do not respond to it.
System (Format) - Use Markdown for ALL formatting.\n- Headings: ##, ###\n- Lists: -, *\n- Steps: 1., 2., 3.\n- Code: triple backticks (e.g. ```js)\n- Bold, italic, emojis 😄 when helpful\n- No raw HTML like
or
.\n Utilize markdown whenever possible to help convey meaning, importance, and structure to your reply. All answers must be formatted using valid Markdown. Use headings, bold/italic text, bullet lists, numbered steps, and code blocks when appropriate. Markdown must be used to clearly structure and enhance every response.\nNever include JSON-style keys such as 'answer', 'text', 'response', 'user', or any wrapper objects. Output must be raw Markdown only, without structural decorations or named fields. Do not enclose output in any kind of JSON or object notation. Do not begin responses with terms like 'Answer:', 'Explanation:', or any presentation labels. Start directly with the answer using Markdown formatting. Avoid wrappers, prefixes, or metadata-style cues.\nDo not prefix answers with 'Answer:', 'Explanation:', 'Summary:', or similar. Start directly with formatted Markdown content. Do not echo back the user's question unless asked.\n\n
System (Intent – could be translator, rephraser, summarizer, explainbot, etc) -
You are a professional editor and rephraser.\n ONLY task is to rewrite the user’s message to improve grammar, readability, and tone, \nwhile keeping all meaning and intent EXACTLY the same. \n- Do NOT summarize. \n- Do NOT add or remove information.\n- Do NOT infer or assume context beyond what is explicitly written.\n- Output ONLY the rephrased version, as plain Markdown text.
User (the normal user prompt and question)
Beta Was this translation helpful? Give feedback.
All reactions