跳到正文
DEV Community· Joy·· 4 小時前AI 評分33

探索其他大型語言模型,以改善 Kinyarwanda 文字生成

Exploring Other Large Language Models for Improving Kinyarwanda Text Generation

AI 導讀

文章比較四款開放權重模型以改善 Kinyarwanda 文字生成,並選擇 Qwen3-4B-Instruct-2507 作為項目下一步測試的模型。它有 4B 參數、262,144 tokens 上下文長度,採用 Apache 2.0 授權,並支援多語言及指令跟隨。作者指出,多語言支援不保證能準確生成 Kinyarwanda,仍須實際測試。

正文

Choosing the Best Open-Source Model for Text Generation

1. Introduction

Text generation is an important task in Natural Language Processing (NLP). It allows computers to generate text from a prompt. For example, when we write “The people of Kicukiro say”, a language model can predict what words should come next.

In our project, we studied GPT-2 and compared it with a tiny GPT model that our group built from scratch. Our tiny GPT was trained on Kinyarwanda news from the KINNEWS dataset.

Our experiments showed that GPT-2 can generate fluent English, but it struggles to continue a sentence correctly in Kinyarwanda. Our tiny GPT generates text that looks more like Kinyarwanda, but its sentences do not always make sense.

GPT-2 has 124 million parameters and was trained mainly on English text. Our tiny GPT has about 0.82 million parameters and was trained on approximately 24 million characters of Kinyarwanda news. This showed us that both model size and training data are important for text generation.

The next step is to find a better language model that can generate useful text and follow instructions. In this blog, I compare four open-weight models and choose the one that is most suitable for improving our project.

2. Models We Considered

Model 1: Qwen3-4B-Instruct-2507

Qwen3-4B-Instruct-2507 was developed by the Qwen team at Alibaba. It has 4 billion parameters and supports a context length of up to 262,144 tokens. It uses the Apache 2.0 licence.

This model is designed to follow instructions, understand text, and generate helpful responses. It also has multilingual capabilities and can handle many different tasks.

One advantage is that it does not require a separate thinking mode to generate its answers. This makes its output easier to use when we want a direct response.

However, it is larger than our original GPT-2 model, so it needs more memory and computing power. We also need to test its Kinyarwanda output instead of assuming that it will always generate correct Kinyarwanda.

Model 2: Qwen3-1.7B

Qwen3-1.7B is another model from Alibaba's Qwen team. It has approximately 1.7 billion parameters and uses the Apache 2.0 licence. Its standard context length is around 32,768 tokens.

Its main advantage is its smaller size compared with Qwen3-4B. This can make it easier to run and faster to test on a computer with limited memory.

It can follow instructions and generate text, making it useful for small NLP applications. However, its smaller size may affect the quality of some responses.

This model would be a good choice if our main concern was reducing memory use. We would still need to compare its Kinyarwanda generation with the output from the larger model.

Model 3: Llama 3.2-3B-Instruct

Llama 3.2-3B-Instruct was developed by Meta. It has approximately 3 billion parameters and a context length of up to 128,000 tokens. It uses the Llama 3.2 Community Licence.

This model is designed for tasks such as text generation, summarisation, and following instructions. It is relatively small compared with many larger language models.

One advantage is that it can generate conversational text and follow user instructions. However, its licence has specific terms, and access to its model files may require accepting Meta's conditions. Its officially supported languages also do not include Kinyarwanda.

This means it is worth considering, but its licence and language limitations make it less convenient for our project.

Model 4: SmolLM3-3B

SmolLM3-3B was developed by Hugging Face and its contributors. It has approximately 3 billion parameters and supports a standard context length of 65,536 tokens, with extensions available for longer contexts. It uses the Apache 2.0 licence.

The model is designed for instruction following, text generation, and reasoning. It is also released with information about its training process, which makes it interesting for learning and research.

Its size makes it a possible option for running on a GPU with limited memory. However, its documented multilingual support focuses on six languages: English, French, Spanish, German, Italian, and Portuguese. Kinyarwanda is not among them.

For our project, we would need to test whether it produces useful Kinyarwanda text before choosing it.

3. Comparison Table

Model Developer Parameters Context length Licence Main strength
Qwen3-4B-Instruct-2507 Alibaba Qwen team 4B 262,144 tokens Apache 2.0 Instruction following and multilingual text generation
Qwen3-1.7B Alibaba Qwen team 1.7B 32,768 tokens Apache 2.0 Smaller size and lower memory needs
Llama 3.2-3B-Instruct Meta 3B 128,000 tokens Llama Community Licence Conversational text and instruction following
SmolLM3-3B Hugging Face and contributors 3B 65,536 tokens by default Apache 2.0 Efficient text generation and transparent training details

Context lengths are the models' documented limits. A longer context does not automatically mean better text generation.

4. The Model Chosen

I would choose Qwen3-4B-Instruct-2507 to improve our text-generation project.

The first reason is its instruction-following ability. We want a model that can receive a prompt and generate a response in the requested format. For example, we could ask it to continue a Kinyarwanda news sentence, produce a short news paragraph, or rewrite text more clearly.

The second reason is its multilingual capability. Our notebook showed that GPT-2 struggles with Kinyarwanda partly because its tokenizer breaks many Kinyarwanda words into smaller pieces. The Kinyarwanda example required about 1.7 times as many tokens as the English example. Qwen3 may handle this task better, but we must test it because multilingual support does not guarantee accurate Kinyarwanda.

The third reason is that it uses the Apache 2.0 licence and its Hugging Face model page provides access to the model files without the gated-access process required by some other models. We can load it directly in a notebook rather than depending on a paid text-generation API.

Can it run on free Google Colab?

Qwen3-4B-Instruct-2507 is a realistic model to test on a free Google Colab T4 GPU with 16 GB of GPU memory. Its 4-billion-parameter size makes local inference more practical than using a much larger model. The exact memory use depends on the precision, context length, and generation settings.

For our first test, we should use a moderate prompt length and generate a limited number of new tokens. If memory becomes a problem, we can try a quantized version.

The model itself does not require a paid API key. However, free Colab GPU access is not guaranteed at all times, and Colab still requires a Google account. We should also check the model's licence terms before using it in a published application.

How will it improve our project?

We can compare Qwen3 with GPT-2 and our tiny GPT using the same Kinyarwanda prompts. For example, we can use the prompt:

"Abaturage bo mu Kicukiro bavuga ko..."

We can then compare the generated text for language quality, sentence meaning, grammar, repetition, and whether it follows the prompt.

We should keep the prompts and generation settings as similar as possible. We can also test English prompts to compare performance across languages.

Our tiny GPT is still valuable because it helps us understand how a transformer works and how training data affects the results. Qwen3 would be an additional model for comparison, not a replacement for the lessons we learned from building our own model.

5. Conclusion

Our experiments showed that generating text is not only about having a large model. The model's training data, tokenizer, and ability to follow instructions also affect the result.

Qwen3-4B-Instruct-2507 is my preferred option because it combines a manageable model size, instruction following, multilingual capabilities, and an Apache 2.0 licence. It is also practical to test on a free Colab T4 GPU, although actual memory use must be checked.

Most importantly, we should not assume that it will automatically produce perfect Kinyarwanda. We need to test it with real Kinyarwanda prompts and compare the results with GPT-2 and our tiny GPT. These tests will help us decide whether it is a useful improvement for our project.

6. References

  1. OpenAI. Language Models are Unsupervised Multitask Learners (2019). https://openai.com/index/better-language-models/

  2. Qwen Team. Qwen3-4B-Instruct-2507 model card. Hugging Face. https://huggingface.co/Qwen/Qwen3-4B-Instruct-2507

  3. Qwen Team. Qwen3-1.7B model card. Hugging Face. https://huggingface.co/Qwen/Qwen3-1.7B

  4. Meta. Llama 3.2 model card and licence information. https://github.com/meta-llama/llama-models/blob/main/models/llama3_2/MODEL_CARD.md

  5. Hugging Face. SmolLM3-3B model card. https://huggingface.co/HuggingFaceTB/SmolLM3-3B

  6. Hugging Face. Transformers documentation. https://huggingface.co/docs/transformers

  7. Vaswani, A. et al. Attention Is All You Need (2017). https://arxiv.org/abs/1706.03762

來源:DEV Community · dev.to