InstrucTurca: An open source instruction tuning dataset for Turkish

How we created a high quality and diverse synthetic instruction tuning dataset for Turkish

Duygu ALTINOK
Google Developer Experts
6 min readAug 9, 2024

--

Since the breakthrough of Large Language Models (LLMs), the AI scene has been buzzing with excitement. Massive datasets like Pile [1] and RefinedWeb [2] have been unleashed into the wild by their creators, changing the game for data access. These data goldmines are now the fuel behind the latest natural language processing wonders. After pre-training on such colossal datasets, many models undergo a transformative process known as instruction fine-tuning. This cherry on top involves training LLMs for specific tasks such as mathematical operations, text summarization, essay and poem writing, and more. Even renowned LLMs like Mighty ChatGPT have embraced this approach, showcasing the power and versatility of instruction fine-tuning in shaping these models for specialized tasks.

Orca and Alpaca — ML is all about cute animals these days. Image credits: author.

One well-known instruction dataset is Alpaca [3], developed by Stanford University researchers. To create this dataset, researchers first crafted a variety of prompts covering a wide range of topics and tasks. These prompts were then fed into GPT-3.5, also known as ChatGPT, for training. Another popular dataset, Orca [4] from Microsoft Research, takes a similar approach. In Orca, GPT-4 serves as the teacher, providing detailed prompts that encourage thorough understanding and step-by-step reasoning. Examples from Alpaca showcase the diversity and depth of the prompts, offering valuable insights for model training:

{
"instruction": "Arrange the given numbers in ascending order.",
"input": "2, 4, 0, 8, 3",
"output": "0, 2, 3, 4, 8."
}
{
"instruction": "Name two types of desert biomes."
"input": "",
"output": "Two types of desert biomes are hot and dry desert, and cold desert."
}

Finding resources for non-English data, like Turkish, can be tough, especially when it comes to large and diverse datasets. Recognizing this challenge, a decision was made to gather a broad range of instructions tailored for the Turkish language. This effort led to the creation of InstrucTurca, the first extensive and diverse instruction tuning dataset designed specifically for Turkish tasks.

InstrucTurca, our cute and freely available instruction tuning dataset for Turkish.

Initially, translating English datasets seemed like a quick fix, but it turned out to be trickier than expected. We faced two main hurdles: finding a reliable translator model and locating one that allowed free use of its outputs without commercial restrictions. This second requirement ruled out most models, especially closed-source ones that don’t permit using their outputs to create competing models. We needed a solution that could be freely used in both academic and commercial settings, leading us to explore open-source models. After some searching, we discovered a Github page listing open LLMs and their usage rights. Among them, Snowflake Arctic [5] stood out as the only multilingual LLM that allowed us to freely use its outputs. Luckily, this model not only speaks Turkish but does so exceptionally well!😁

We compiled the dataset content from several instruction tuning datasets including:

  • BI55/MedText
  • checkai/instruction-poems
  • garage-bAInd/Open-Platypus
  • Locutusque/ColumnedChatCombined
  • nampdn-ai/tiny-codes
  • Open-Orca/OpenOrca
  • pubmed_qa
  • TIGER-Lab/MathInstruct
  • TokenBender/code_instructions_120k_alpaca_style

We ended up with around 2.8M dataset instances.

Next comes the translation. For the translation part, we conversated with Snowflake Arctic on Poe.com for a seamless chat experience. We started outchat with a greeting, explained the task and then sent instruction-output pairs one by one via a Python script. The conversation looked like below:

Initiation of our chat with Snowflake Arctic.

Results are good and quite usable in general. Some examples from the dataset look like:

{
"Input": "Sonraki cümleyi yazın. Patricia, Carrie'den Cadılar Bayramı kostümü
için ona ahşap bir kalkan yapmasını istedi çünkü Seçenekler şunlardır:
(I) Patricia'nın hayal gücü yoktur.; (II) Carrie'nin hayal gücü yoktur; Cevap:",

"Output": "Cevap: (I) Patricia'nın hayal gücü yoktur. Patricia, Carrie'den
Cadılar Bayramı kostümü için ona tahta bir kalkan yapmasını istedi çünkü
Patricia'nın hayal gücü yoktu. Cadılar Bayramı kostümlerinin sonsuz
olanaklarına ve geliştirilebilecek sayısız yaratıcı fikre rağmen Patricia,
kendisini şenlikler sırasında neyin öne çıkarabileceği konusunda kararsız
kaldı. Genellikle benzersiz konseptler üzerinde beyin fırtınası yapmakta
zorlandığından, ayırt edici bir unsur olarak kıyafetine ahşap bir kalkan
eklemeyi seçti. Carrie, daha yaratıcı ve zanaatkarlık konusunda daha yetenekli
olduğundan, bu meydan okumayı memnuniyetle kabul etti. Arkadaşına destek olma
ve aynı zamanda Patricia'nın kostümünü gerçekten benzersiz kılacak geleneksel
kalkan tasarımını renklendirme fırsatını yakaladı
.............."
}
------------------------------
{"Input": "Python'un yerleşik range() işlevinin işlevselliğini açıklayın.",

"Output": "range() işlevi, Python'da belirli bir aralıkta bir sayı dizisi
oluşturmak için kullanılan yerleşik bir işlevdir. İstenilen sayı dizisini
içeren, yinelenebilen veya bir listeye dönüştürülebilen, aralık türünde
değişmez bir sıra nesnesi döndürür. \n\nAralık işlevi en fazla üç bağımsız
değişken alabilir; şu sözdizimine sahip bir başlangıç, bir bitiş ve bir adım
değeri: `aralık(başlangıç, durdurma, adım)` - Başlangıç ​​argümanı dizideki ilk
sayıyı tanımlar (varsayılanı 0'dır). - Durdurma argümanı, aralığın durma
değerine ulaşmadan önce duracağı sıranın sonunu tanımlar (zorunlu bir
argümandır), yani durma değeri diziye dahil değildir.- Adım argümanı dizideki
her sayı arasındaki artışı tanımlar (varsayılanı 1'dir), azalan bir dizi
oluşturmak için de negatif değerler alabilir. İşte 'range()' fonksiyonunun
nasıl kullanılacağına dair bir örnek:- 0'dan 5'e kadar bir sayı dizisi
oluşturmak için`(6) aralığındaki i için: print(i) # Çıktı: 0 1 2 3 4 5`
- 2'den 8'e kadar 2'lik artışlarla bir sayı dizisi oluşturmak için:`(2, 9, 2)
aralığındaki i için: print(i) # Çıktı: 2 4 6 8`"
}
----------------------
{"Input": "Karen, Donald ve 6 çocukları, Tom, Eva ve 4 çocuklarıyla bir sahil
evini paylaşıyorlar. Havuzda 16 ayak varsa havuzda olmayan kaç kişi vardır?",

"Output": "Karen, Donald ve 6 çocukları 1+1+6 = 8 kişilik bir partidir.
Tom ve Evan ve 4 çocukları 1+1+4 = 6 kişilik bir partidir. Sahil evinde toplam
8 + 6 = 14 kişi var. Havuzda 16 ayak var ve herkesin 2 ayağı var yani havuzda
16/2 = 8 kişi var\nSahil evinde toplam 14 kişi var ve havuzda 8 kişi var yani
14-8 = 6 kişi havuzda değil. Cevap 6"}
--------------------
{"Input": "Dikdörtgen piramidin tabanı 5 cm uzunluğunda ve 3 cm genişliğinde
olan dikdörtgen bir tabana sahiptir. Piramidin yüksekliği 8 cm'dir. Piramidin
hacmini bulun.",

"Output": "Dikdörtgen piramidin hacmini bulmak için aşağıdaki formülü
kullanabiliriz: Hacim = (1/3) × Taban Alanı × Yükseklik
Dikdörtgen piramidin taban alanı dikdörtgenin alanıdır ve aşağıdaki formül
kullanılarak bulunabilir: Taban Alanı = Uzunluk × Genişlik
Bu durumda uzunluk 5 cm, genişlik 3 cm olduğundan taban alanı şöyle olur:
Taban Alanı = 5 cm × 3 cm = 15 cm²
Şimdi aşağıdaki formülü kullanarak piramidin hacmini bulabiliriz:
Hacim = (1/3) × Taban Alanı × Yükseklik
Hacim = (1/3) × 15 cm² × 8 cm
Hacim = (1/3) × 120 cm³
Hacim = 40 cm³
Yani dikdörtgen piramidin hacmi 40 santimetreküptür."
}

Looks good indeed! Within the dataset, there are some lengthy pairs that are perfect for training a LLM. They provide rich context and support chain reasoning. These pairs cover diverse topics like coding, mathematics, essay writing, and more.

Curating datasets, especially with LLMs known for issues like hallucinations, is not without its challenges. Following the translation phase, we carefully reviewed the dataset to identify and remove any instances of hallucinations. It became apparent that when the output from Arctic was unsuccessful, it often deviated from the promised format (mostly the absence of <input> and <output> tags in the Arctic answers). Initially starting with roughly 2.8M translations, our refinement process based on this criterion reduced the dataset to around 2.6M instances. Subsequently, we conducted further refinements using additional rules.:

  • The original text and translated text shouldn’t significantly differ in length
  • Newline and punctuation character positions should match in the original text and translated text in coding type outputs
  • Numeric tokens should be the same across the translation.

After the second elimination, we left with around 2.5M instances and published our dataset at HuggingFace.

Though we put some effort into curating the dataset, most of the heavy lifting was made by Snowflake Arctic. Multilingual LLMs indeed can be made quite valuable synthetic data generators for low-resource languages.

And that’s the story of how we put together a dataset that’s legit, free for all, and ready for business. We hope our journey inspires other researchers to dive in, create, and share with the community. Let’s hope our dataset kicks off some cool projects and motivates folks to build and share even more datasets!😊

--

--

Duygu ALTINOK
Google Developer Experts

Senior NLP Engineer from Berlin. Deepgram member, spaCy contributor. Enjoys quality code, in love with grep. Youtube: https://www.youtube.com/c/NLPwithDuygu