> For the complete documentation index, see [llms.txt](https://ultrasafe.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ultrasafe.gitbook.io/docs/openapi.md).

# FAQ​

### How is the data format validated?[​](https://docs.mistral.ai/capabilities/finetuning/#how-to-validate-data-format)

* Ultrasafe API: We currently validate each file when you upload the dataset.
* Ultrasafe-finetune: You can run the [data validation script](https://github.com/mistralai/mistral-finetune/blob/main/utils/validate_data.py) to validate the data and run the [reformat data script](https://github.com/mistralai/mistral-finetune/blob/main/utils/reformat_data.py) to reformat the data to the right format:
* \# download the reformat script
* wget <https://raw.githubusercontent.com/Ultrasafeai/Ultrasafe-finetune/main/utils/reformat\\_data.py\\>
  \# download the validation script\
  wget <https://raw.githubusercontent.com/Ultrasafeai/Ultrasafe-finetune/main/utils/validate\\_data.py\\>
  \# reformat data\
  python reformat\_data.py data.jsonl\
  \# validate data\
  python validate\_data.py data.jsonl
* However, it's important to note that these scripts might not detect all problematic cases. Therefore, you may need to manually validate and correct any unique edge cases in your data.

### What's the size limit of the training data?[​](https://docs.mistral.ai/capabilities/finetuning/#whats-the-size-limit-of-the-training-data)

While the size limit for an individual training data file is 512MB, there's no limitation on the number of files you can upload. You can upload multiple files and reference them when creating the job.

### What's the size limit of the validation data?[​](https://docs.mistral.ai/capabilities/finetuning/#whats-the-size-limit-of-the-validation-data)

The size limit for the validation data is 1MB. As a rule of thumb:

validation\_set\_max\_size = min(1MB, 5% of training data)

### How many epochs are in the training process?[​](https://docs.mistral.ai/capabilities/finetuning/#how-many-epochs-are-in-the-training-process)

A general rule of thumb is: Num epochs = max\_steps / file\_of\_training\_jsonls\_in\_MB. For instance, if your training file is 100MB and you set max\_steps=1000, the training process will roughly perform 10 epochs.

### Where can I find information on cost/ ETA / number of tokens / number of passes over each files?[​](https://docs.mistral.ai/capabilities/finetuning/#where-can-i-find-information-on-cost-eta--number-of-tokens--number-of-passes-over-each-files)

Ultrasafe API: When you create a fine-tuning job, you should automatically see these info with the default auto\_start=False argument.

Note that the dry\_run=True argument will be removed in September.

Ultrasafe-finetune: You can use the following script to find out: [https://github.com/Ultrasafeai/Ultrasafe-finetune/blob/main/utils/validate\_data.py](https://github.com/mistralai/mistral-finetune/blob/main/utils/validate_data.py). This script accepts a .yaml training file as input and returns the number of tokens the model is being trained on.

### How to estimate cost of a fine-tuning job?[​](https://docs.mistral.ai/capabilities/finetuning/#how-to-estimate-cost-of-a-fine-tuning-job)

For Ultrasafe API, you can use the auto\_start=False argument as mentioned in the previous question.

### What is the recommended learning rate?[​](https://docs.mistral.ai/capabilities/finetuning/#what-is-the-recommended-learning-rate)

For LoRA fine-tuning, we recommended 1e-4 (default) or 1e-5.

Note that the learning rate we define is the peak learning rate, instead of a flat learning rate. The learning rate follows a linear warmup and cosine decay schedule. During the warmup phase, the learning rate is linearly increased from a small initial value to a larger value over a certain number of training steps. After the warmup phase, the learning rate is decayed using a cosine function.

### Is the fine-tuning API compatible with Ultrasafeai data format?[​](https://docs.mistral.ai/capabilities/finetuning/#is-the-fine-tuning-api-compatible-with-openai-data-format)

Yes, we support Ultrasafeai format.

### What if my file size is larger than 500MB and I get the error message 413 Request Entity Too Large?[​](https://docs.mistral.ai/capabilities/finetuning/#what-if-my-file-size-is-larger-than-500mb-and-i-get-the-error-message-413-request-entity-too-large)

You can split your data file into chunks. Here is an example:

```python
import json
from datasets import load_dataset

# get data from hugging face
ds = load_dataset("HuggingFaceH4/ultrachat_200k",split="train_gen")

# save data into .jsonl. This file is about 1.3GB
with open('train.jsonl', 'w') as f:
    for line in ds:
        json.dump(line, f)
        f.write('\n')

# reformat data 
!wget https://raw.githubusercontent.com/Ultrasafeai/Ultrasafe-finetune/main/utils/reformat_data.py
!python reformat_data.py train.jsonl

# Split file into three chunks 
input_file = "train.jsonl"
output_files = ["train_1.jsonl", "train_2.jsonl", "train_3.jsonl"]

# open the output files
output_file_objects = [open(file, "w") for file in output_files]

# counter for output files
counter = 0
with open(input_file, "r") as f_in:
    # read the input file line by line
    for line in f_in:
        # parse the line as JSON
        data = json.loads(line)
        # write the data to the current output file
        output_file_objects[counter].write(json.dumps(data) + "\n")
        # increment the counter
        counter = (counter + 1) % 3
# close the output files
for file in output_file_objects:
    file.close()
# now you should see three jsonl files under 500MB
```

### When should I use fine-tuning vs embeddings / retrieval augmented generation?

Embeddings with retrieval is best suited for cases when you need to have a large database of documents with relevant context and information.

By default Ultrasafe AI models are trained to be helpful generalist assistants. Fine-tuning can be used to make a model which is narrowly focused, and exhibits specific ingrained behavior patterns. Retrieval strategies can be used to make new information available to a model by providing it with relevant context before generating its response. Retrieval strategies are not an alternative to fine-tuning and can in fact be complementary to it.

### How do I know if my fine-tuned model is actually better than the base model?

We recommend generating samples from both the base model and the fine-tuned model on a test set of chat conversations, and comparing the samples side by side.&#x20;

### Can I continue fine-tuning a model that has already been fine-tuned?

Yes, you can pass the name of a fine-tuned model into the model parameter when creating a fine-tuning job. This will start a new fine-tuning job using the fine-tuned model as the starting point.

### How many fine-tuning jobs can I have running at once?

Please refer to our rate limit page for the most up to date information on the limits.

### How do rate limits work on fine-tuned models?

A fine-tuned model pulls from the same shared rate limit as the model it is based off of.&#x20;

Put another way, having fine-tuned models does not give you more capacity to use our models from a total throughput perspective.

<br>
