Text Generation
Transformers
Safetensors
PEFT
lora
qwen
code-generation
linear-algebra
python
conversational
Instructions to use vllm/qwen-linear-algebra-coder with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use vllm/qwen-linear-algebra-coder with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="vllm/qwen-linear-algebra-coder") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("vllm/qwen-linear-algebra-coder", device_map="auto") - PEFT
How to use vllm/qwen-linear-algebra-coder with PEFT:
Task type is invalid.
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use vllm/qwen-linear-algebra-coder with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "vllm/qwen-linear-algebra-coder" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "vllm/qwen-linear-algebra-coder", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/vllm/qwen-linear-algebra-coder
- SGLang
How to use vllm/qwen-linear-algebra-coder with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "vllm/qwen-linear-algebra-coder" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "vllm/qwen-linear-algebra-coder", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "vllm/qwen-linear-algebra-coder" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "vllm/qwen-linear-algebra-coder", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use vllm/qwen-linear-algebra-coder with Docker Model Runner:
docker model run hf.co/vllm/qwen-linear-algebra-coder
|
Download README.md from vllm/qwen-linear-algebra-coder: direct link, hf CLI and curl.
- Browser
- Download file 3.92 kB
-
https://huggingface.co/vllm/qwen-linear-algebra-coder/resolve/main/README.md
- Command line
-
hf download hf://vllm/qwen-linear-algebra-coder/README.md
-
curl -L -o README.md https://huggingface.co/vllm/qwen-linear-algebra-coder/resolve/main/README.md
3.92 kB
| license: mit | |
| library_name: transformers | |
| base_model: Qwen/Qwen3-1.7B | |
| tags: | |
| - lora | |
| - qwen | |
| - peft | |
| - code-generation | |
| - linear-algebra | |
| - python | |
| pipeline_tag: text-generation | |
| <!-- vllm-ci-copy --> | |
| > [!NOTE] | |
| > This is a copy of [premjatin/qwen-linear-algebra-coder](https://huggingface.co/premjatin/qwen-linear-algebra-coder) at commit `f016ab8`, made on 2026-10-30. vLLM CI uses this checkpoint and the original is on a personal account, so we keep a copy here to reduce supply-chain risk. | |
| # qwen-linear-algebra-coder | |
| This repository contains a LoRA (Low-Rank Adaptation) fine-tuned version of `Qwen/Qwen3-1.7B`. This model is specialized for generating Python code to solve linear algebra problems described in natural language. | |
| ## Model Details | |
| ### Model Description | |
| This is a specialized code-generation model. It takes a textual description of a linear algebra problem and outputs a Python script, typically using the `numpy` library, that solves it. | |
| - **Developed by:** [premjatin](https://huggingface.co/premjatin) | |
| - **Model type:** LoRA fine-tune | |
| - **Language(s):** English, Python | |
| - **License:** MIT | |
| - **Finetuned from model:** `Qwen/Qwen3-1.7B` | |
| ## How to Get Started with the Model | |
| Use the code below to get started with the model. This example uses 4-bit quantization for efficient inference on consumer hardware. | |
| ```python | |
| # First, install necessary libraries | |
| # !pip install transformers torch peft accelerate bitsandbytes | |
| import torch | |
| from peft import PeftModel | |
| from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig | |
| BASE_MODEL_ID = "Qwen/Qwen3-1.7B" | |
| ADAPTER_MODEL_ID = "premjatin/qwen-linear-algebra-coder" | |
| quantization_config = BitsAndBytesConfig(load_in_4bit=True) | |
| # Load the base model and tokenizer | |
| base_model = AutoModelForCausalLM.from_pretrained( | |
| BASE_MODEL_ID, | |
| torch_dtype=torch.bfloat16, | |
| device_map="auto", | |
| trust_remote_code=True, | |
| quantization_config=quantization_config, | |
| ) | |
| tokenizer = AutoTokenizer.from_pretrained(BASE_MODEL_ID, trust_remote_code=True) | |
| tokenizer.pad_token = tokenizer.eos_token | |
| # Load the LoRA adapter | |
| model = PeftModel.from_pretrained(base_model, ADAPTER_MODEL_ID) | |
| # --- Define a problem --- | |
| problem_description = """ | |
| Find the eigenvalues and eigenvectors of the following 3x3 matrix: | |
| [[4, 0, 1], | |
| [-2, 1, 0], | |
| [-2, 0, 1]] | |
| """ | |
| # --- Create a structured prompt --- | |
| prompt = f"""### INSTRUCTION: | |
| You are an AI assistant that generates Python code to solve linear algebra problems. | |
| ### PROBLEM: | |
| {problem_description} | |
| ### PYTHON SOLUTION: | |
| ``` | |
| # --- Generate the solution --- | |
| inputs = tokenizer(prompt, return_tensors="pt").to(model.device) | |
| with torch.no_grad(): | |
| outputs = model.generate( | |
| **inputs, | |
| max_new_tokens=256, | |
| do_sample=False, | |
| ) | |
| response_text = tokenizer.decode(outputs[0], skip_special_tokens=True) | |
| print(response_text) | |
| ``` | |
| Training Details | |
| Training Data | |
| The model was fine-tuned on a custom dataset of approximately 10,000 problem-and-solution pairs related to linear algebra. The data was structured to teach the model how to convert a word problem into a Python script. | |
| Training Hyperparameters | |
| The model was trained using the PEFT library with the following LoRA configuration: | |
| { | |
| "r": 16, | |
| "lora_alpha": 32, | |
| "lora_dropout": 0.05, | |
| "bias": "none", | |
| "task_type": "CAUSAL_LM", | |
| "target_modules": [ | |
| "down_proj", "k_proj", "v_proj", | |
| "gate_proj", "up_proj", "q_proj", "o_proj" | |
| ] | |
| } | |
| Bias, Risks, and Limitations | |
| Code Correctness: The generated code is not guaranteed to be 100% correct or optimal. Always review and test the code before using it in a production environment. | |
| Scope: The model's capabilities are limited to the types of problems present in its training data. It may not perform well on highly complex or novel problems. | |
| Library Bias: The model was primarily trained on solutions using numpy and will heavily favor it in its responses. | |