|
|
--- |
|
|
title: StarCoder2 |
|
|
emoji: ✨2️⃣✨ |
|
|
colorFrom: yellow |
|
|
colorTo: blue |
|
|
sdk: gradio |
|
|
sdk_version: 5.12.0 |
|
|
app_file: app.py |
|
|
pinned: true |
|
|
license: mit |
|
|
short_description: Latest Coding Model By🤗Huggingface & Friends-101 languages! |
|
|
--- |
|
|
|
|
|
StarCoder2 |
|
|
|
|
|
🌟 Latest Coding Model By 🤗 Huggingface & Friends - Supports 101 Programming Languages! 🌟 |
|
|
|
|
|
StarCoder2 is an advanced coding model designed to support a wide range of programming tasks, from code generation to bug fixing, across 101 programming languages. With state-of-the-art performance and seamless integration, StarCoder2 is your go-to tool for coding excellence. |
|
|
|
|
|
📜 License |
|
|
|
|
|
StarCoder2 is distributed under the Apache 2.0 License. |
|
|
|
|
|
🏅 Model Badges |
|
|
|
|
|
Languages Supported: 101 |
|
|
|
|
|
Framework Compatibility: Hugging Face Transformers |
|
|
|
|
|
Model Size: 15B Parameters |
|
|
|
|
|
🌐 Model Capabilities |
|
|
|
|
|
🗣 Languages Supported |
|
|
|
|
|
StarCoder2 supports 101 programming languages, including but not limited to: |
|
|
|
|
|
Python, JavaScript, Java, C++, Go, Rust, HTML, CSS, SQL, TypeScript, and more. |
|
|
|
|
|
🚀 Performance |
|
|
|
|
|
StarCoder2 achieves high accuracy and performance on multiple coding benchmarks, making it a reliable choice for complex programming tasks. |
|
|
|
|
|
🔧 Tasks |
|
|
|
|
|
StarCoder2 excels at: |
|
|
|
|
|
Code Generation: Create boilerplate code or complete functions. |
|
|
|
|
|
Code Completion: Predict the next lines of code with context. |
|
|
|
|
|
Bug Fixing: Identify and resolve errors in your code. |
|
|
|
|
|
📥 Installation and Usage |
|
|
|
|
|
🛠 Installation |
|
|
|
|
|
Ensure you have the Hugging Face Transformers library installed. You can do so by running: |
|
|
|
|
|
pip install git+https://github.com/huggingface/transformers.git |
|
|
|
|
|
Alternatively, use the provided requirements.txt file: |
|
|
|
|
|
pip install -r requirements.txt |
|
|
|
|
|
💻 Usage Examples |
|
|
|
|
|
Here’s how you can load the StarCoder2 model and generate code: |
|
|
|
|
|
Python Code Example: |
|
|
|
|
|
from transformers import AutoModelForCausalLM, AutoTokenizer |
|
|
|
|
|
# Load the model and tokenizer |
|
|
model_name = "bigcode/starcoder2-15b" |
|
|
tokenizer = AutoTokenizer.from_pretrained(model_name) |
|
|
model = AutoModelForCausalLM.from_pretrained(model_name, trust_remote_code=True) |
|
|
|
|
|
# Input prompt |
|
|
prompt = "def fibonacci(n):" |
|
|
inputs = tokenizer(prompt, return_tensors="pt") |
|
|
|
|
|
# Generate code |
|
|
outputs = model.generate(inputs["input_ids"], max_new_tokens=50) |
|
|
print(tokenizer.decode(outputs[0], skip_special_tokens=True)) |
|
|
|
|
|
JavaScript Code Example: |
|
|
|
|
|
const { AutoModelForCausalLM, AutoTokenizer } = require('@huggingface/transformers'); |
|
|
|
|
|
async function generateCode() { |
|
|
const modelName = 'bigcode/starcoder2-15b'; |
|
|
const tokenizer = await AutoTokenizer.from_pretrained(modelName); |
|
|
const model = await AutoModelForCausalLM.from_pretrained(modelName); |
|
|
|
|
|
const prompt = 'function calculateFactorial(num) {'; |
|
|
const inputs = tokenizer.encode(prompt, { return_tensors: 'pt' }); |
|
|
|
|
|
const output = await model.generate(inputs, { max_new_tokens: 50 }); |
|
|
console.log(tokenizer.decode(output[0])); |
|
|
} |
|
|
|
|
|
generateCode(); |
|
|
|
|
|
📚 Additional Resources |
|
|
|
|
|
Hugging Face Model Hub |
|
|
|
|
|
Explore StarCoder2 on Hugging Face: StarCoder2-15B Model Card |
|
|
|
|
|
Configuration Reference |
|
|
|
|
|
Detailed configuration options are available in the documentation. |
|
|
|
|
|
📖 Citation |
|
|
|
|
|
If you use StarCoder2 in your research or projects, please cite the following: |
|
|
|
|
|
@misc{starcoder2, |
|
|
author = {Huggingface and Friends}, |
|
|
title = {StarCoder2: A State-of-the-Art Coding Model}, |
|
|
year = {2025}, |
|
|
url = {https://huggingface.co/bigcode/starcoder2-15b/blob/main/README.md} |
|
|
} |
|
|
|
|
|
🤝 Community and Support |
|
|
|
|
|
We welcome contributions and feedback from the community! Here’s how you can get involved: |
|
|
|
|
|
Report Issues: Submit issues on GitHub. |
|
|
|
|
|
Contribute: Fork the repository and make pull requests to improve StarCoder2. |
|
|
|
|
|
Join Discussions: Participate in discussions on Hugging Face Forums. |
|
|
|
|
|
Thank you for using StarCoder2! 🚀 |