--- base_model: unsloth/Qwen2.5-Coder-7B-Instruct-bnb-4bit library_name: peft pipeline_tag: text-generation tags: - base_model:adapter:unsloth/Qwen2.5-Coder-7B-Instruct-bnb-4bit - lora - sft - transformers - trl - unsloth license: apache-2.0 datasets: - open-r1/codeforces-cots --- # Model Card for Model ID # Model Card for SaffalPoosh/reasoning_cpp_llm 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 example_problem = """ A 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? Constraints: Time limit per test: 2.0 seconds Memory limit per test: 256.0 megabytes 1 ≤ m, n ≤ 100 Grid cells are either 0 (empty) or 1 (obstacle). Input Format: The first line contains two integers m and n — the dimensions of the grid. The next m lines each contain n integers (0 or 1) representing the grid. Output Format: Print a single integer — the number of unique paths. Example: Input: 3 3 0 0 0 0 1 0 0 0 0 """ ``` ### Model Loading and Inference ```python from unsloth import FastLanguageModel from transformers import TextStreamer from transformers import TextIteratorStreamer from threading import Thread # Model configuration model_path = "SaffalPoosh/reasoning_cpp_llm" max_seq_length = 16000 dtype = None load_in_4bit = True # Load model and tokenizer model, tokenizer = FastLanguageModel.from_pretrained( model_name=model_path, max_seq_length=max_seq_length, dtype=dtype, load_in_4bit=load_in_4bit, local_files_only=False ) # This will download the base model and then patch by applying the LoRA adapters FastLanguageModel.for_inference(model) # Prepare Input Data input_text = example_problem inputs = tokenizer(input_text, return_tensors="pt") inputs = {k: v.to("cuda") for k, v in inputs.items()} # Initialize the text streamer text_streamer = TextIteratorStreamer(tokenizer, skip_special_tokens=False) # Perform Inference with streaming stream_catcher = Thread( target=model.generate, kwargs={ **inputs, "do_sample": True, "streamer": text_streamer, "max_new_tokens": 10000 } ) stream_catcher.start() # Stream output to console and file with open("output.txt", "w") as f: for token in text_streamer: print(token, end="", flush=True) f.write(token) stream_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 - **Max Sequence Length**: 16,000 tokens - **Quantization**: 4-bit loading supported - **Hardware Requirements**: CUDA-compatible GPU recommended ## Training Details - **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: 1. Problem analysis and reasoning 2. Algorithm explanation 3. Complete C++ implementation 4. Time and space complexity analysis ## Requirements ```python 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. ## How to Get Started with the Model Use the code below to get started with the model. [More Information Needed] ## Training Details ### Training Data [More Information Needed] ### Training Procedure #### Preprocessing [optional] [More Information Needed] #### Training Hyperparameters - **Training regime:** [More Information Needed] #### Speeds, Sizes, Times [optional] [More Information Needed] ## Evaluation ### Testing Data, Factors & Metrics #### Testing Data [More Information Needed] #### Factors [More Information Needed] #### Metrics [More Information Needed] ### Results [More Information Needed] #### Summary ## Model Examination [optional] [More Information Needed] ## Environmental Impact Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700). - **Hardware Type:** [More Information Needed] - **Hours used:** [More Information Needed] - **Cloud Provider:** [More Information Needed] - **Compute Region:** [More Information Needed] - **Carbon Emitted:** [More Information Needed] ## Technical Specifications [optional] ### Model Architecture and Objective [More Information Needed] ### Compute Infrastructure [More Information Needed] #### Hardware [More Information Needed] #### Software [More Information Needed] ## Citation [optional] **BibTeX:** [More Information Needed] **APA:** [More Information Needed] ## Glossary [optional] [More Information Needed] ## More Information [optional] [More Information Needed] ## Model Card Authors [optional] [More Information Needed] ## Model Card Contact [More Information Needed] ### Framework versions - PEFT 0.17.1