This is a QLoRA adapter trained on C++ coding tasks and designed for reasoning-based code generation. The model specializes in solving algorithmic problems with step-by-step reasoning and generating optimized C++ solutions.
Example Usage
Problem Example
python
1example_problem ="""
2A robot is situated at the top-left corner of an m x n grid. The robot can only move either down or right at any point in time. It wants to reach the bottom-right corner of the grid. Some cells in the grid are blocked by obstacles. How many unique paths can the robot take to reach the destination?
34Constraints:
5Time limit per test: 2.0 seconds
6Memory limit per test: 256.0 megabytes
71 ≤ m, n ≤ 100
8Grid cells are either 0 (empty) or 1 (obstacle).
910Input Format:
11The first line contains two integers m and n — the dimensions of the grid.
12The next m lines each contain n integers (0 or 1) representing the grid.
1314Output Format:
15Print a single integer — the number of unique paths.
1617Example:
18Input:
193 3
200 0 0
210 1 0
220 0 0
23"""
Model Loading and Inference
python
1from unsloth import FastLanguageModel
2from transformers import TextStreamer
3from transformers import TextIteratorStreamer
4from threading import Thread
56# Model configuration7model_path ="SaffalPoosh/reasoning_cpp_llm"8max_seq_length =160009dtype =None10load_in_4bit =True1112# Load model and tokenizer13model, tokenizer = FastLanguageModel.from_pretrained(14 model_name=model_path,15 max_seq_length=max_seq_length,16 dtype=dtype,17 load_in_4bit=load_in_4bit,18 local_files_only=False19)2021# This will download the base model and then patch by applying the LoRA adapters22FastLanguageModel.for_inference(model)2324# Prepare Input Data25input_text = example_problem
26inputs = tokenizer(input_text, return_tensors="pt")27inputs ={k: v.to("cuda")for k, v in inputs.items()}2829# Initialize the text streamer30text_streamer = TextIteratorStreamer(tokenizer, skip_special_tokens=False)3132# Perform Inference with streaming33stream_catcher = Thread(34 target=model.generate,35 kwargs={36**inputs,37"do_sample":True,38"streamer": text_streamer,39"max_new_tokens":1000040}41)4243stream_catcher.start()4445# Stream output to console and file46withopen("output.txt","w")as f:47for token in text_streamer:48print(token, end="", flush=True)49 f.write(token)5051stream_catcher.join()
Model Details
Model Type: QLoRA Fine-tuned Language Model
Base Model: [Specify base model if known]
Training Focus: C++ algorithmic problem solving with reasoning
Training Method: QLoRA (Quantized Low-Rank Adaptation)
Dataset: C++ coding tasks with reasoning annotations
Task Type: Code generation with step-by-step reasoning
Optimization: Focused on algorithmic problem solving
Usage Notes
The model generates reasoning-based solutions for C++ programming problems
Supports streaming inference for real-time output
The output.txt file contains the complete generated solution
Designed to handle competitive programming style problems with constraints
Output Format
The model typically generates:
Problem analysis and reasoning
Algorithm explanation
Complete C++ implementation
Time and space complexity analysis
Requirements
pip install unsloth transformers torch
Hardware Requirements
GPU: CUDA-compatible GPU (recommended)
Memory: Sufficient VRAM for 4-bit quantized model
Storage: Space for base model download and adapter weights
Model Details
Model Description
Developed by: [More Information Needed]
Funded by [optional]: [More Information Needed]
Shared by [optional]: [More Information Needed]
Model type: [More Information Needed]
Language(s) (NLP): [More Information Needed]
License: [More Information Needed]
Finetuned from model [optional]: [More Information Needed]
Model Sources [optional]
Repository: [More Information Needed]
Paper [optional]: [More Information Needed]
Demo [optional]: [More Information Needed]
Uses
Direct Use
[More Information Needed]
Downstream Use [optional]
[More Information Needed]
Out-of-Scope Use
[More Information Needed]
Bias, Risks, and Limitations
[More Information Needed]
Recommendations
Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.