code-search-net/code_search_net
Viewer • Updated • 4.14M • 48.5k • 337
How to use raimondskrauklis/gpt-neo-1.3b-code-conversation with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="raimondskrauklis/gpt-neo-1.3b-code-conversation") # Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("raimondskrauklis/gpt-neo-1.3b-code-conversation")
model = AutoModelForCausalLM.from_pretrained("raimondskrauklis/gpt-neo-1.3b-code-conversation", device_map="auto")How to use raimondskrauklis/gpt-neo-1.3b-code-conversation with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "raimondskrauklis/gpt-neo-1.3b-code-conversation"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "raimondskrauklis/gpt-neo-1.3b-code-conversation",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'docker model run hf.co/raimondskrauklis/gpt-neo-1.3b-code-conversation
How to use raimondskrauklis/gpt-neo-1.3b-code-conversation with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "raimondskrauklis/gpt-neo-1.3b-code-conversation" \
--host 0.0.0.0 \
--port 30000
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:30000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "raimondskrauklis/gpt-neo-1.3b-code-conversation",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'docker run --gpus all \
--shm-size 32g \
-p 30000:30000 \
-v ~/.cache/huggingface:/root/.cache/huggingface \
--env "HF_TOKEN=<secret>" \
--ipc=host \
lmsysorg/sglang:latest \
python3 -m sglang.launch_server \
--model-path "raimondskrauklis/gpt-neo-1.3b-code-conversation" \
--host 0.0.0.0 \
--port 30000
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:30000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "raimondskrauklis/gpt-neo-1.3b-code-conversation",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'How to use raimondskrauklis/gpt-neo-1.3b-code-conversation with Docker Model Runner:
docker model run hf.co/raimondskrauklis/gpt-neo-1.3b-code-conversation
A fine-tuned version of GPT-Neo 1.3B optimized for both conversational AI and Python code generation. This model combines instruction-following capabilities with comprehensive Python programming knowledge through a multi-layer fine-tuning approach.
Base Model: EleutherAI/gpt-neo-1.3B
Fine-tuning Approach: Multi-layer sequential training
Specializations: Conversation + Python Code Generation
from transformers import GPTNeoForCausalLM, GPT2Tokenizer
model = GPTNeoForCausalLM.from_pretrained("raimondskrauklis/gpt-neo-1.3b-code-conversation")
tokenizer = GPT2Tokenizer.from_pretrained("raimondskrauklis/gpt-neo-1.3b-code-conversation")
tokenizer.pad_token = tokenizer.eos_token
# Code generation example
prompt = "Human: Write a Python function that calculates the factorial of a number\nAssistant:"
inputs = tokenizer(prompt, return_tensors="pt")
outputs = model.generate(**inputs, max_length=200, temperature=0.7, do_sample=True)
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
print(response)
Code Explanation
pythonprompt = "Human: Explain how binary search works in Python\nAssistant:"
inputs = tokenizer(prompt, return_tensors="pt")
outputs = model.generate(**inputs, max_length=300, temperature=0.7)
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
print(response)
Debugging Assistance
pythonprompt = "Human: Why does this Python code give a list index error?\ncode: for i in range(len(data)+1): print(data[i])\nAssistant:"
inputs = tokenizer(prompt, return_tensors="pt")
outputs = model.generate(**inputs, max_length=250, temperature=0.7)
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
print(response)
Training Methodology
Multi-Layer Fine-tuning Strategy
Base Selection: Started with EleutherAI's GPT-Neo 1.3B pre-trained model
Layer 1 - Conversational: Fine-tuned on dialogue data for instruction-following
Layer 2 - Code Enhancement: Specialized training on CodeSearchNet Python dataset
Quality Assurance: Rigorous filtering for high-quality code-documentation pairs
Technical Implementation
Distributed Training: 8x AMD MI250X GPUs with proper CPU-GPU affinity
Batch Configuration: Per-device batch size of 4 with gradient accumulation
Learning Rate: 5e-6 with cosine annealing schedule
Sequence Length: 512 tokens maximum
Epochs: 2 epochs over full dataset for optimal convergence
Performance Metrics
Training Loss Progression: 0.9556 → 0.4554 (excellent convergence)
Dataset Coverage: 362,059 Python code examples
Training Efficiency: ~11,315 batches per epoch
Model Size: ~5.3GB (2x safetensors files)
Context Length: 512 tokens
Limitations
Language Focus: Primarily trained on Python code (limited other programming languages)
Code Complexity: Best performance on functions under 100 lines
Validation Required: Generated code should be tested before production use
Knowledge Cutoff: Training data reflects pre-2024 coding practices
Context Window: Limited to 512 tokens for generation
Ethical Considerations
Code Review: All generated code should be reviewed for security and correctness
Bias Awareness: May reflect biases present in training data
Responsible Use: Not intended for malicious code generation
Attribution: Based on open-source datasets and models
Technical Specifications
Model Type: Causal Language Model (GPT-Neo architecture)
Parameters: 1.3 billion
Vocabulary Size: 50,257 tokens
Hidden Size: 2,048
Attention Heads: 16
Layers: 24
Context Length: 2,048 tokens (training used 512)
Citation
bibtex@misc{gpt-neo-code-conversation-2025,
title={GPT-Neo 1.3B Enhanced for Code and Conversation},
author={Raimonds Krauklis},
year={2025},
howpublished={Hugging Face Model Hub},
url={https://huggingface.co/raimondskrauklis/gpt-neo-1.3b-code-conversation},
note={Fine-tuned on European HPC infrastructure using CodeSearchNet dataset}
}
Acknowledgments
Base Model: EleutherAI for GPT-Neo 1.3B
Dataset: CodeSearchNet by GitHub/Microsoft Research
Infrastructure: European high-performance computing systems
Framework: Hugging Face Transformers and PyTorch ecosystem
Model Card Contact
For questions about this model, please open an issue in the model repository or contact through Hugging Face.
Base model
EleutherAI/gpt-neo-1.3B