There's a lot of tutorials online that uses raw text affix with arcane syntax to indicate document boundary and accessed through Huggingface datasets.Dataset object through the text key. E.g.
from datasets import load_dataset
dataset_name = "mlabonne/guanaco-llama2-1k"
dataset = load_dataset(dataset_name, split="train")
dataset["text"][42]
[out]:
<s>[INST] ¿Cuáles son los actuales presidentes de la región de Sur América? Enumérelos en una lista con su respectivo país. [/INST] A fecha del 13 de febrero de 2023, estos son los presidentes de los países de Sudamérica, según Wikipedia:
-Argentina: Alberto Fernández
-Bolivia: Luis Arce
-Brasil: Luiz Inácio Lula da Silva
-Chile: Gabriel Boric
-Colombia: Gustavo Petro
-Ecuador: Guillermo Lasso
-Paraguay: Mario Abdo Benítez
-Perú: Dina Boluarte
-Uruguay: Luis Lacalle Pou
-Venezuela: Nicolás Maduro
-Guyana: Irfaan Ali
-Surinam: Chan Santokhi
-Trinidad y Tobago: Paula-Mae Weekes </s>
But machine translation datasets are usually structured in 2 parts, source and target text with sentence_eng_Latn and sentence_deu_Latn keys, e.g.
valid_data = load_dataset("facebook/flores", "eng_Latn-deu_Latn", streaming=False,
split="dev")
valid_data[42]
[out]:
{'id': 43,
'URL': 'https://en.wikinews.org/wiki/Hurricane_Fred_churns_the_Atlantic',
'domain': 'wikinews',
'topic': 'disaster',
'has_image': 0,
'has_hyperlink': 0,
'sentence_eng_Latn': 'The storm, situated about 645 miles (1040 km) west of the Cape Verde islands, is likely to dissipate before threatening any land areas, forecasters say.',
'sentence_deu_Latn': 'Prognostiker sagen, dass sich der Sturm, der etwa 645 Meilen (1040 km) westlich der Kapverdischen Inseln befindet, wahrscheinlich auflösen wird, bevor er Landflächen bedroht.'}
The key is to re-format the data from a traditional machine translation dataset that splits the source and target text and piece them up together in a format that the model expects.
For the Mistral 7B model specifically, it usually expects:
<s> andwhere[INST] ... [/INST][/INST]symbol[INST] ... [/INST]E.g. if we want to use a translation prompt as such "Translate English to German:",
[out]:
Then the normal fine-tuning Mistral-7b scripts could just read the
textkey in the dataset, e.g.Requires
And if you are in a Jupyter environment, you'll need to reset the kernel after installing accelerate, so:
Then: