Gallium-350M (lfm2.5-350m-reasoning v3.1.1)

Gallium Logo

Gallium is a lightweight code reasoning and generation model built upon the base LFM2.5-350M model. It offers accurate and quick code snippet and long-form code generation in all major programming languages. It's small size (350M parameters) allows it to run comfortably on laptop grade GPUs.

The 350M model has been SFT trained on code reasoning traces found here with further RL training carried out via. a GRPO algorithm. This endows the model with enhanced reasoning capabilities which allows it to serve higher quality and hallucination-free generations.

It serves as a significant upgrade from the previous GemCod-270M and GemCod-R model families whilst having relatively minor bloat to inference time and space requirements.

This model also offers Q/A and subject matter expert capabilities on code related subjects.


Estimated parameters: ~350M

Architecture: LFM2.5

Intended use: Code snippet and long-form generations from natural language, instruction following and advanced reasoning


Training data

Phase-1

Phase-2

Usage

Install requirements:

pip install -r requirements.txt
pip install transformers datasets accelerate safetensors

Usage (Hugging Face Hub)

You can load it directly from HuggingFace:

import torch
from transformers import AutoModelForCausalLM, AutoTokenizer, TextStreamer


device = "cuda" if torch.cuda.is_available() else "cpu"

model_id = "DireDreadlord/Gallium-350M"
model = AutoModelForCausalLM.from_pretrained(
    model_id,
    device_map="auto",
    dtype="auto"
)
model.to(device)
tokenizer = AutoTokenizer.from_pretrained(model_id)
streamer = TextStreamer(tokenizer, skip_prompt=True, skip_special_tokens=False)

prompt = "Can you reason about the following leetcode question: Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target. You may assume that each input would have exactly one solution, and you may not use the same element twice. You can return the answer in any order. Please provide a detailed reasoning and explanation for your answer."

input_ids = tokenizer.apply_chat_template(
    [{"role": "user", "content": prompt}],
    add_generation_prompt=True,
    return_tensors="pt",
    tokenize=True,
)["input_ids"].to(device)

output = model.generate(
    input_ids,
    do_sample=True,
    temperature=0.4,
    top_k=50,
    repetition_penalty=1.05,
    max_new_tokens=2048,
    streamer=streamer,
)

For optimal long-form generation(with reasoning), set max_new_tokens=2048

Limitations

  • Model for experimental use only; users should employ it as such under license.
Downloads last month
56
Safetensors
Model size
0.4B params
Tensor type
BF16
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for DireDreadlord/Gallium-350M

Finetuned
(47)
this model

Dataset used to train DireDreadlord/Gallium-350M

Collection including DireDreadlord/Gallium-350M