Cırtdan: an open Azerbaijani chatbot model with personas
Cırtdan is an open Azerbaijani chatbot model on mT5-large that talks in the role of a persona: how it works, how to run it and where its limits are.
Cırtdan is an open Azerbaijani chatbot model that we published on Hugging Face in November 2023. You give it a short description of a persona in Azerbaijani and the start of a dialogue, and it continues the conversation in that role. In this article we explain how the model was trained, how to run it, what its limits are and how it relates to the chatbots businesses use today.
What Cırtdan is
- Base model: mT5-large.
- Training data: more than 1,500 persona chat sessions translated from Russian.
- Training settings: 3 epochs, batch size 1 with gradient accumulation of 32, the Adafactor optimiser, learning rate 1e-4.
- Licence: MIT, so it can be used in commercial projects as well.
Cırtdan is a base version. It shows that a compact open model can hold a conversation in Azerbaijani and keep to a given character, but for robust answers it should be fine-tuned further on a specific downstream task.
How to run it
Install the libraries first; the tokenizer needs SentencePiece:
pip install transformers[sentencepiece] torch
The model card gives the following example:
import torch
from transformers import AutoTokenizer, MT5ForConditionalGeneration
model_name = 'learningmachineaz/cirtdan-azerbaijani-chatbot'
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = MT5ForConditionalGeneration.from_pretrained(model_name).to(device)
model.eval()
prompt = "<SC6>Sən bir oğlansan, müxtəlif məsələlər üzrə məsləhətçi. Çox ağıllısan. Həmsöhbətinə kömək etmək istəyirəm. Dialoqu davam et:\nHəmsöhbət: salam! necəsən?\nSən: <extra_id_0>"
input_ids = tokenizer.encode(prompt, return_tensors='pt').to(device)
out_ids = model.generate(
input_ids=input_ids,
do_sample=True,
temperature=0.9,
max_new_tokens=64,
top_p=0.85,
top_k=2,
repetition_penalty=1.2
)
output = tokenizer.decode(out_ids[0][1:])
if '</s>' in output:
output = output[:output.find('</s>')].strip()
output = output.replace('<extra_id_0>', '').strip()
output = output.split('Həmsöhbət')[0].strip()
print(output)
The prompt format
The prompt has three parts, and the model expects all of them:
<SC6>, a service token at the very beginning.- The persona: a few sentences in Azerbaijani about who the bot is. In the example: "Sən bir oğlansan, müxtəlif məsələlər üzrə məsləhətçi. Çox ağıllısan. Həmsöhbətinə kömək etmək istəyirəm." (a young man who gives advice on various matters, very clever, who wants to help the person he talks to).
- The dialogue:
Dialoqu davam et:("continue the dialogue"), then the lines of the conversation, whereHəmsöhbət:is the user andSən:is the bot. The last lineSən: <extra_id_0>marks the place the model fills in.
To keep a conversation going, append each new pair of lines to the dialogue part and send the whole prompt again.
Cleaning the output
The model's raw output contains service tokens, and sometimes it starts writing the user's next line too. That is why the code cuts the text at </s>, removes <extra_id_0> and keeps only what comes before the next Həmsöhbət.
Generation settings
Sampling with temperature=0.9, top_p=0.85 and top_k=2 keeps answers lively but close to the most likely words; repetition_penalty=1.2 discourages loops; max_new_tokens=64 keeps replies short, as in a chat. Because sampling is on, the same prompt can give different answers on each run.
Limits to know about
- Translated data. The training dialogues were translated from Russian, so the model tends to imitate people with Russian names.
- A base model. Without further fine-tuning on your task, answers are not reliable enough for real customers.
- No knowledge of your business. The model only knows what it saw during training; it cannot look up your prices, documents or order statuses.
- Short replies. With the recommended settings an answer is at most 64 new tokens.
If you want to adapt it, fine-tune it on dialogues from your own domain written in the same prompt format, with the persona that fits your use case.
How business chatbots are built today
Cırtdan is useful for research, teaching and experiments with Azerbaijani dialogue. A production chatbot for a company is built differently. It answers from the company's own knowledge base (website, documents, spreadsheets, catalogue), not from what a model happened to memorise; it can take actions such as checking an order status or making a booking; it hands a conversation over to a person with its history; and it is protected against attempts to trick it into leaking internal data. You can see such a bot at work in the chat on this website.
Try it or build your own
The model is on Hugging Face, and the project page has the details. If you need an Azerbaijani chatbot for your customers or staff, see our chatbot development service or describe your task.
- Hugging Face
- mT5
- Chatbot
- Azerbaijani