# Model Tuning and Re-Tuning Problems

**URL:** <https://discuss.huggingface.co/t/model-tuning-and-re-tuning-problems/157715>\
**Category:** Models\
**Created:** [June 2, 2025, 2:40pm UTC](https://discuss.huggingface.co/t/model-tuning-and-re-tuning-problems/157715 "2025-06-02T14:40:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![neo911](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/neo911/32/48665_2.png) [@neo911](https://discuss.huggingface.co/u/neo911)\
**Post date:** [June 2, 2025, 2:40pm UTC](https://discuss.huggingface.co/t/model-tuning-and-re-tuning-problems/157715/1 "2025-06-02T14:40:47Z")

</div>

🚀 **Working on Fine-Tuning LLMs – Need Some Expert Advice!** 🤖

I’ve been experimenting with model training using both general user data and tool-specific data from our platform.  
Initially, I combined (shuffled) both types of data for fine-tuning. Later, I shifted to a **phased learning approach** :

➡ **Phase 1:** Fine-tuned the model with general platform data.  
➡ **Phase 2:** Re-tuned it with only tool-related data using adapters from Phase 1.

Despite this structured approach, I’m still facing a few recurring issues:

1️⃣ Why does the model **randomly return the system prompt** (e.g., the one provided in `system` role) in its replies?  
2️⃣ Why does it **ask for tool details even during general greetings** or unrelated platform queries?  
3️⃣ Why does it **miss some required fields** when constructing tool calls?  
4️⃣ Why does it **invent new tool parameters** not defined in the schema?  
5️⃣ Why doesn’t it **ask for all required fields in plain text consistently**?  
6️⃣ After a tool call, why does it **repeat previous answers instead of asking for required fields again** if the same query is asked?

🔍 If anyone has tackled similar issues while fine-tuning LLMs (e.g., using LoRA adapters or phased training), I’d love to hear your thoughts or tips!

💬 Feel free to comment or DM—any insights are truly appreciated. Thanks in advance!

---

<div class="post-metadata">

**Author:** ![Mdrnfox](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/mdrnfox/32/47695_2.png) [@Mdrnfox](https://discuss.huggingface.co/u/Mdrnfox)\
**Post date:** [June 2, 2025, 3:14pm UTC](https://discuss.huggingface.co/t/model-tuning-and-re-tuning-problems/157715/2 "2025-06-02T15:14:01Z")

</div>

Did your fine tuning contain the system prompts and the model was trained on seeing that?  
You could add in the system prompt telling the model to not repeat the system prompt ( at inference) or strip it out from the output. Probably would use the first method to save token count.

1. I think you are encountering a default behavior learned from your data and the model can’t differentiate from user greetings and the user queries asking about the tools. I would add synthetic data of data containing normal NLP interactions between model and user to off set this to your phase 2. You could also add a label to the prompt to detect if the user is actually asking for a tool and to determine to output metadata.

2. My assumption, but your data is missing a consistent schema format and the model has underlearned the schema. You probably have data that is needed in some inputs and trimming the schemas in other inputs. You could include required tool schemas and optional tool schemas. You can validate the output json to confer correctness.

3. Again there is sample imbalance to know what it needs.

4. You need to work on the cache/retrieval logic or reissue the call again as a new query..

Hope this helps 🙂

---

<div class="post-metadata">

**Author:** ![Pimpcat-AU](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/pimpcat-au/32/48989_2.png) [@Pimpcat-AU](https://discuss.huggingface.co/u/Pimpcat-AU)\
**Post date:** [June 10, 2025, 8:01pm UTC](https://discuss.huggingface.co/t/model-tuning-and-re-tuning-problems/157715/3 "2025-06-10T20:01:59Z")

</div>

# Always clean and standardize your dataset

def clean\_dataset(data):  
# Remove repeated system prompts and deduplicate examples  
cleaned =   
seen = set()  
for ex in data:  
key = (ex[‘prompt’], ex[‘completion’])  
if key not in seen:  
# Strip system prompts from completions  
ex[‘completion’] = ex[‘completion’].replace(ex.get(‘system\_prompt’, ‘’), ‘’)  
cleaned.append(ex)  
seen.add(key)  
return cleaned

# Validate all tool calls for missing or invented fields

def validate\_tool\_calls(tool\_calls, schema):  
valid\_calls =   
for call in tool\_calls:  
# Remove parameters not in schema  
call[‘parameters’] = {k: v for k, v in call[‘parameters’].items() if k in schema}  
# Add missing fields as None or default  
for field in schema:  
if field not in call[‘parameters’]:  
call[‘parameters’][field] = None  
valid\_calls.append(call)  
return valid\_calls

# Ensure plain text prompts always require all fields

def enforce\_required\_fields(prompt, required\_fields):  
for field in required\_fields:  
if field not in prompt:  
prompt += f"\nPlease provide the following required field: {field}"  
return prompt

# Example usage:

# data = load\_your\_data()

# schema = {‘field1’, ‘field2’, ‘field3’}

# data = clean\_dataset(data)

# for ex in data:

# ex[‘tool\_calls’] = validate\_tool\_calls(ex[‘tool\_calls’], schema)

# ex[‘prompt’] = enforce\_required\_fields(ex[‘prompt’], schema)

# Optional: add randomness to reduce repeated answers

import random  
def shuffle\_answers(answers):  
random.shuffle(answers)  
return answers

# If model is repeating previous answers, you may need to add noise or sample from a diverse training set.

Solution provided by Triskel Data Deterministic AI.
