TULLUS = I quickly converted the model.bin to model.safetensors file after pulling the base repo.

A few weeks ago i made a mini gradio server that was special built for running a multimodal. So now i made it load the new artifac, and more INFOS Below ⤵

CodeParrot-Multi 🦜 (small)

CodeParrot-Multi 🦜 is a GPT-2 model (110M parameters) trained to generate code in 9 programming languages: "Java", "JavaScript", "PHP", "Python", "C#", "C++", "GO", "Ruby" and "TypeScript".

Older pythorch.model.bin Usage

You can load the CodeParrot-Multi model and tokenizer directly in transformers:

from transformers import AutoTokenizer, AutoModelWithLMHead
  
tokenizer = AutoTokenizer.from_pretrained("codeparrot/codeparrot-small-multi")
model = AutoModelWithLMHead.from_pretrained("codeparrot/codeparrot-small-multi")

inputs = tokenizer("def hello_world():", return_tensors="pt")
outputs = model(**inputs)

or with a pipeline:

from transformers import pipeline

pipe = pipeline("text-generation", model="codeparrot/codeparrot-small-multi")
outputs = pipe("def hello_world():")

########################################

New Usage for the model.safetensors :]

import torch
from transformers import AutoTokenizer, AutoModelForCausalLM

model_id = "TULLUS/codeparrot-small-multi"

tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(model_id)

prompt = "def hello_world():"
inputs = tokenizer(prompt, return_tensors="pt")

with torch.no_grad():
    outputs = model.generate(
        **inputs, 
        max_new_tokens=32,
        pad_token_id=tokenizer.eos_token_id
    )

print(tokenizer.decode(outputs[0], skip_special_tokens=True))

Training

The model was trained on the small Github code small after near deduplication, a subset of Github code dataset with the following settings:

Config Value
Batch size 192
Context size 1024
Training steps 300'000
Gradient accumulation 2
Gradient checkpointing False
Learning rate 5e-4
Weight decay 0.1
Warmup steps 2000
Schedule Cosine

The training was executed on 16 x A100 (40GB) GPUs. This setting amounts to roughly 58 billion tokens.

Performance

We evaluated the model on OpenAI's HumanEval benchmark which consists of programming challenges:

Metric Value
pass@1 --%
pass@10 --%
pass@100 --%

The pass@k metric tells the probability that at least one out of k generations passes the tests.

Resources


TULLUS Edits

Laboratory initialized. Ready for input.

import time
import torch
import json
import base64
import io
import logging
import os
from typing import Optional, Dict, Any
from PIL import Image
from fastapi import FastAPI, HTTPException
from fastapi.staticfiles import StaticFiles
from fastapi.responses import FileResponse
from pydantic import BaseModel
from transformers import AutoTokenizer, AutoModelForCausalLM
import uvicorn
import transformers


# --- Configuration ---
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
MODEL_PATH = "TULLUS"

these stats load at server start in my mini server

▶ MODEL
{
  "name": "gpt2",
  "architecture": "['GPT2LMHeadModel']",
  "parameters": "111,008,256",
  "dtype": "torch.float16"
}


 RUNTIME
{
  "transformers_version": "5.15.0",
  "pytorch_version": "2.9.1+rocm7.2.1.gitff65f5bc",
  "rocm_hip": "7.2.53211-e1a6bc5663",
  "python_version": "3.12.13"
}


▶ GPU
{
  "0": {
    "name": "AMD Radeon RX 9070 XT",
    "total_memory": "15.92 GiB",
    "current_memory": "15.12 GiB"
  }
}

✅ Code completion prompt (model fills in the rest):

"def add_numbers(a, b):\n return"

"def add_numbers(a, b):\n return"
+ a.toString() + " + b.toString();",
"def add_strings(a, b):\n return" + a.toString() + " = 'abc' + b.toString();\n",
"def add_ints(a, b):\n return" + a.toString() + " = 1 + 2;\n",
"def add_floats(a, b):\n return" + a.toString() + " = 3.1415926535897932384626433832795;\n",
"def add_doubles(

{ "input_tokens": 15, "output_tokens": 128, "generation_time_sec": 1.068, "tokens_per_sec": 119.84, "parameters_used": { "max_new_tokens": 128, "temperature": 0.2, "top_p": 0.95, "do_sample": true, "repetition_penalty": 1.2, "pad_token_id": 0, "eos_token_id": 0 } }

✅ Java completion prompt:

"public class Main {\n public static int add(int a, int b) {\n"

+
" return a+b;\n" +
"}\n\n");
}

@Test
void testAdd() {
assertParse("public class Main {\n public static int add(int a, int b) {\n" +
" return a+b; }\n}\n", false);

assertParse("public class Main {\n public static int add(int a, int b) {\n" +
" return a+b; }\n}\n", true);

assertParse("public class Main {\n public static int add(int a, int b) {\

{ "input_tokens": 20, "output_tokens": 128, "generation_time_sec": 1.043, "tokens_per_sec": 122.69, "parameters_used": { "max_new_tokens": 128, "temperature": 0.2, "top_p": 0.95, "do_sample": true, "repetition_penalty": 1.2, "pad_token_id": 0, "eos_token_id": 0 } }


// Convert Python dictionary lookup logic to C++ std::map // Python: val = my_dict.get(key, -1)

#include #include

int get_value_or_default(const std::map<std::string, int>& my_dict, const std::string& key) {

if (my_dict.find(key) != my_dict.end())
return my_dict[key];

// Default value is 0
return 0;
}

{ "input_tokens": 76, "output_tokens": 40, "generation_time_sec": 0.823, "tokens_per_sec": 48.61, "parameters_used": { "max_new_tokens": 128, "temperature": 0.2, "top_p": 0.95, "do_sample": true, "repetition_penalty": 1.2, "pad_token_id": 0, "eos_token_id": 0 } }

Downloads last month
43
Safetensors
Model size
0.1B params
Tensor type
F16
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Datasets used to train TULLUS/codeparrot-small-multi

Collection including TULLUS/codeparrot-small-multi