跳到正文
DEV Community· Rose Umutesi·· 3 小時前AI 評分29

超越 TinyGPT 和 GPT-2:為詩歌生成項目挑選合適的大語言模型

# Beyond TinyGPT and GPT-2: Finding the Right LLM for The Poem Generation Project ✍️🤖

AI 導讀

作者比較 Qwen3-4B-Instruct-2507、SmolLM3-3B 和 Phi-4-mini-instruct,評估它們的參數規模、上下文窗口、授權及記憶體需求,為詩歌生成項目挑選後續實驗模型。

正文

Introduction

Large Language Models (LLMs) have changed how we generate and interact with text. They can write stories, answer questions, follow instructions, and create different forms of creative content. For my Natural Language Processing (NLP) project, I have been exploring Poem Generation, which focuses on generating poems from text prompts.

I previously explored TinyGPT and GPT-2 for poem generation. These models helped me understand how language models learn patterns from text and generate new sequences of words. However, I want to explore whether newer, instruction-tuned models can produce more coherent, creative, and relevant poems while following specific instructions.

In this blog, I research three open-weight LLMs: Qwen3-4B-Instruct-2507, SmolLM3-3B, and Phi-4-mini-instruct. I compare their features, licences, context windows, and practical requirements before selecting one as my proposed model for further experimentation.

1. Exploring Three LLMs

1.1 Qwen3-4B-Instruct-2507

Qwen3-4B-Instruct-2507 was developed by the Qwen team. It contains approximately 4 billion parameters and is designed to follow instructions, understand text, reason, and generate responses to different prompts.

One of its important features is its ability to handle open-ended tasks, making it a promising candidate for creative writing. For example, I could ask it to write a four-line poem about agriculture, use a hopeful tone, or follow a particular rhyme scheme.

The model supports a context window of up to 262,144 tokens and is released under the Apache 2.0 licence. Its model weights require approximately 8 GB in BF16 or FP16 precision, before accounting for additional memory needed during inference.

Why it interests me: Its instruction-following and open-ended text-generation capabilities could help me generate poems that follow a topic, mood, length, and style specified by the user.

Model card: https://huggingface.co/Qwen/Qwen3-4B-Instruct-2507

1.2 SmolLM3-3B

SmolLM3-3B was developed by Hugging Face. It is a compact language model with approximately 3 billion parameters. Despite its relatively small size, it supports instruction following, text generation, and reasoning-related tasks.

The model has a native context length of 65,536 tokens and can support longer contexts, up to 128,000 tokens, with the appropriate configuration. It is released under the Apache 2.0 licence. Its weights require approximately 6 GB at full 16-bit precision, although actual memory use depends on the runtime and generation settings.

SmolLM3 is particularly interesting because Hugging Face provides information about its training process and configurations, making it useful for learning and experimentation.

Why it interests me: Its smaller size may make it a practical candidate for experimenting with poem generation under limited computing resources. I would like to see whether it can produce good poems without requiring as much memory as larger models.

Model card: https://huggingface.co/HuggingFaceTB/SmolLM3-3B

1.3 Phi-4-mini-instruct

Phi-4-mini-instruct was developed by Microsoft and contains approximately 3.8 billion parameters. It is a compact model designed for instruction-following tasks, reasoning, mathematics, and coding.

It supports a context window of up to 128,000 tokens and is released under the MIT licence. Its weights require approximately 7.6 GB at 16-bit precision, excluding runtime overhead and other memory requirements.

Although the model is known for its reasoning capabilities, I am also interested in evaluating its ability to generate creative text. Its performance on reasoning tasks does not automatically mean it will produce the best poetry, so testing it on my project is important.

Why it interests me: It offers another relatively small model that can follow prompts. I want to investigate whether it can balance creativity, coherence, and adherence to poetry instructions.

Model card: https://huggingface.co/microsoft/Phi-4-mini-instruct

2. Comparing the Models

The following table summarizes the main features relevant to my project.

Feature Qwen3-4B-Instruct-2507 SmolLM3-3B Phi-4-mini-instruct
Developer Qwen team Hugging Face Microsoft
Parameters 4 billion 3 billion 3.8 billion
Context window 262,144 tokens 65,536 native; extendable to 128,000 128,000 tokens
Licence Apache 2.0 Apache 2.0 MIT
Main strengths Instruction following, reasoning, open-ended generation Compact size, instruction following, open training details Reasoning, instruction following, coding
Approximate 16-bit weight memory 8 GB 6 GB 7.6 GB
Potential for poem generation Following detailed creative prompts Efficient creative-writing experiments Exploring coherence and prompt adherence

Note: Memory figures are approximate estimates for model weights only. Actual requirements are higher because of the key-value cache, runtime overhead, and generation settings. Context-window support also does not mean the full context can be used within a particular GPU's memory limits.

3. Which Model Will I Choose?

After reviewing the three candidates, my proposed choice is Qwen3-4B-Instruct-2507 for further experimentation with my Poem Generation project.

My first reason is instruction following. Poetry prompts can contain several requirements at once, such as a topic, emotional tone, number of lines, target audience, and rhyme pattern. I want a model that can respond to these instructions rather than generate a general poem that ignores some of the requirements.

My second reason is its reported improvements in open-ended text generation and instruction following. These capabilities appear relevant to creative writing. However, I will need to test the model to determine whether those general capabilities translate into better poems.

My third reason is accessibility. The model is available through Hugging Face under the Apache 2.0 licence, and it can be run locally in an environment such as Google Colab without paying an API fee for each generation. Its approximately 8 GB of 16-bit weights make it a possible candidate for a free Colab T4 GPU with 16 GB of VRAM. However, runtime overhead and the context length must be managed carefully, and successful loading is not guaranteed in every configuration.

Finally, I want to compare it with the models I previously explored, TinyGPT and GPT-2. This will help me understand whether moving to a more recent instruction-tuned model offers meaningful benefits for my particular project.

This is a proposed selection based on model documentation and expected suitability, not a conclusion from completed benchmark experiments.

4. How Will I Evaluate My Choice?

To avoid selecting a model based only on its description, I plan to evaluate Qwen3-4B-Instruct-2507, SmolLM3-3B, and Phi-4-mini-instruct against my previous TinyGPT and GPT-2 approaches.

I will give the models the same set of prompts, for example:

  • Write a short poem about a farmer growing potatoes.
  • Write an eight-line poem about hope and perseverance.
  • Generate a poem about nature using a happy tone.
  • Write a poem with a specified rhyme pattern.

I will evaluate the generated poems using the following criteria:

  1. Relevance: Does the poem address the requested topic?
  2. Coherence: Do the lines make sense together?
  3. Creativity: Does the poem use interesting language and imagery?
  4. Instruction following: Does it follow the requested length, tone, and format?
  5. Repetition: Does it repeat words, phrases, or ideas unnecessarily?
  6. Efficiency: How long does generation take, and how much memory does it use?

Where possible, I will use consistent generation settings and a simple evaluation rubric. I will also review the poems myself because creative quality cannot be measured fully by a single numerical metric.

The results will help me decide whether Qwen3 is genuinely a better fit or whether one of the smaller alternatives offers a better balance between output quality and computing requirements.

Conclusion

Exploring these three models has helped me understand that selecting an LLM is not simply about choosing the model with the most parameters. The licence, memory requirements, instruction-following ability, context window, and suitability for the intended task are also important.

Qwen3-4B-Instruct-2507 is my proposed choice because its documented instruction-following and open-ended generation capabilities align with the goals of my Poem Generation project. SmolLM3-3B and Phi-4-mini-instruct remain useful alternatives that I would like to test.

My next step is to run the models on the same prompts and compare their outputs with TinyGPT and GPT-2. Ultimately, the goal is not just to use a newer model, but to find one that produces poems that are more relevant, coherent, creative, and responsive to the user's instructions.

References

  1. Qwen Team. Qwen3-4B-Instruct-2507 Model Card. https://huggingface.co/Qwen/Qwen3-4B-Instruct-2507
  2. Hugging Face. SmolLM3-3B Model Card. https://huggingface.co/HuggingFaceTB/SmolLM3-3B
  3. Microsoft. Phi-4-mini-instruct Model Card. https://huggingface.co/microsoft/Phi-4-mini-instruct
  4. NLP course materials. Introduction to Large Language Models, slides on open models, model selection, and LLM limitations.

來源:DEV Community · dev.to