In order to explore the potential of small models, I have attempted to build a series of them, which are available in the
NanoLM Collections
.
This is NanoLM-0.3B-Instruct-v1.1. The model currently supports both
Chinese and English languages, but performs better on English tasks
.
Model Details
The tokenizer and model architecture of NanoLM-0.3B-Instruct-v1.1 are the same as
Qwen/Qwen2-0.5B
, but the number of layers has been reduced from 24 to 12. As a result, NanoLM-0.3B-Instruct-v1.1 has only 0.3 billion parameters, with approximately
180 million non-embedding parameters
. Despite this, NanoLM-0.3B-Instruct-v1.1 still demonstrates strong instruction-following capabilities.
Here are some examples. For reproducibility purposes, I've set
do_sample
to
False
. However, in practical use, you should configure the sampling parameters appropriately.
First, you should load the model as follows:
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM
model_path = 'Mxode/NanoLM-0.3B-Instruct-v1.1'
model = AutoModelForCausalLM.from_pretrained(
model_path,
torch_dtype=torch.bfloat16,
device_map="auto",
)
tokenizer = AutoTokenizer.from_pretrained(model_path)
Next, define a
get_response
function for easy reuse:
# Traditional Chinese
prompt2 = "列印出1到100之間的所有質數。"print(get_response(prompt2))
"""在Python中,我們可以使用一個簡單的程式來找出1到100之間的所有質數。我們可以使用一個函數來檢查一個數是否是質數,然後使用一個循環來檢查每個數是否是質數。以下是使用Python的解決方案:```pythondef is_prime(n): if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False i += 6 return Truefor i in range(1, 101): if is_prime(i): print(i)```這個程式會輸出1到100之間的所有質數。"""
Example 3 - English
# English
prompt3 = "How can I retrieve the current version number of a Python package that I'm working on? Also, is there a standard location where this version number is stored?"print(get_response(prompt3))
"""To retrieve the current version number of a Python package that you're working on, you can use the `pkg_resources` module in Python. Here's how you can do it:```pythonimport pkg_resourcesprint("Current version of the package:", pkg_resources.get_distribution("your_package_name").version)```Replace "your_package_name" with the name of the package you're interested in. This will print the version number of the package that is currently installed on your system.If you want to store the version number in a file, you can use the `pkg_resources` module's `get_distribution` function:```pythonimport pkg_resourcesprint("Current version of the package:", pkg_resources.get_distribution("your_package_name").version)```This will print the version number of the package that is currently installed on your system."""
# Self recognition
prompt5_1 = "你是谁"print(get_response(prompt5_1))
prompt5_2 = "who are you"print(get_response(prompt5_2))
"""我是通义千问,由阿里云开发的AI助手。我被设计用来回答各种问题、提供信息和与用户进行对话。有什么我可以帮助你的吗?I am Qwen, a large language model created by Alibaba Cloud. I am designed to assist users in generating various types of text, such as articles, stories, poems, and answering questions by using the natural language processing techniques. How can I assist you today?"""
NanoLM-0.3B-Instruct-v1.1 huggingface.co is an AI model on huggingface.co that provides NanoLM-0.3B-Instruct-v1.1's model effect (), which can be used instantly with this Mxode NanoLM-0.3B-Instruct-v1.1 model. huggingface.co supports a free trial of the NanoLM-0.3B-Instruct-v1.1 model, and also provides paid use of the NanoLM-0.3B-Instruct-v1.1. Support call NanoLM-0.3B-Instruct-v1.1 model through api, including Node.js, Python, http.
NanoLM-0.3B-Instruct-v1.1 huggingface.co is an online trial and call api platform, which integrates NanoLM-0.3B-Instruct-v1.1's modeling effects, including api services, and provides a free online trial of NanoLM-0.3B-Instruct-v1.1, you can try NanoLM-0.3B-Instruct-v1.1 online for free by clicking the link below.
Mxode NanoLM-0.3B-Instruct-v1.1 online free url in huggingface.co:
NanoLM-0.3B-Instruct-v1.1 is an open source model from GitHub that offers a free installation service, and any user can find NanoLM-0.3B-Instruct-v1.1 on GitHub to install. At the same time, huggingface.co provides the effect of NanoLM-0.3B-Instruct-v1.1 install, users can directly use NanoLM-0.3B-Instruct-v1.1 installed effect in huggingface.co for debugging and trial. It also supports api for free installation.
NanoLM-0.3B-Instruct-v1.1 install url in huggingface.co: