Model-calculator.

Works well with simple calculations, but fails with complex ones.

Here's a 6-million parameters model.

Usage

import torch
from transformers import AutoTokenizer, AutoModelForCausalLM

tokenizer = AutoTokenizer.from_pretrained("georgiyozhegov/calculator-8m")
model = AutoModelForCausalLM.from_pretrained("georgiyozhegov/calculator-8m")

prompt = "find 2 + 3\nstep"

inputs = tokenizer(prompt, return_tensors="pt", return_token_type_ids=False)

with torch.no_grad():
    outputs = model.generate(
        input_ids=inputs["input_ids"],
        attention_mask=inputs["attention_mask"],
        max_length=32,
        do_sample=True,
        top_k=50,
        top_p=0.98
    )

# Cut the rest
count = 0
for index, token in enumerate(outputs[0]):
    if token == 6: count += 1
    if count >= 2: break

output = tokenizer.decode(outputs[0][:index])
print(output)
Downloads last month
26
Safetensors
Model size
8.46M params
Tensor type
F32
·
Inference Examples
This model does not have enough activity to be deployed to Inference API (serverless) yet. Increase its social visibility and check back later, or deploy to Inference Endpoints (dedicated) instead.

Dataset used to train georgiyozhegov/calculator-8m

Space using georgiyozhegov/calculator-8m 1

Collection including georgiyozhegov/calculator-8m