Text Generation
Transformers
Safetensors
English
Italian
llama
code
conversational
text-generation-inference
Instructions to use chrisnic/Python_Ass with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use chrisnic/Python_Ass with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="chrisnic/Python_Ass") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("chrisnic/Python_Ass") model = AutoModelForCausalLM.from_pretrained("chrisnic/Python_Ass", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=256) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use chrisnic/Python_Ass with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "chrisnic/Python_Ass" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "chrisnic/Python_Ass", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/chrisnic/Python_Ass
- SGLang
How to use chrisnic/Python_Ass with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "chrisnic/Python_Ass" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "chrisnic/Python_Ass", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
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 "chrisnic/Python_Ass" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "chrisnic/Python_Ass", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use chrisnic/Python_Ass with Docker Model Runner:
docker model run hf.co/chrisnic/Python_Ass
File size: 3,183 Bytes
821f24e 078efeb 8c15b58 821f24e 66460ba 821f24e 2ef5c6b | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | ---
license: llama3.1
language:
- en
- it
base_model:
- meta-llama/Llama-3.1-8B
pipeline_tag: text-generation
library_name: transformers
tags:
- code
---
# Python Code Assistant based on LLaMA 3.1
This model is a specialized Python coding assistant, fine-tuned from LLaMA 3.1 8B Instruct using a two-stage training approach with carefully curated Python programming datasets.
## Model Description
The model has been trained to assist with Python programming tasks through a progressive fine-tuning approach:
### First Training Stage
- Base Model: LLaMA 3.1 8B Instruct
- Dataset: [iamtarun/python_code_instructions_18k_alpaca](https://huggingface.co/datasets/iamtarun/python_code_instructions_18k_alpaca)
- Training Focus: Understanding Python programming instructions and generating appropriate code responses
### Second Training Stage
- Dataset: [flytech/python-codes-25k](https://huggingface.co/datasets/flytech/python-codes-25k)
- Focus: Enhancing code generation capabilities and understanding of advanced Python concepts
### Training Methodology
The model employs several advanced training techniques to ensure optimal performance:
- **LoRA Fine-tuning Parameters**:
- Rank (r): 8
- Alpha: 16
- Dropout: 0.1
- Target Modules: Query and Value Projections
- **Training Optimizations**:
- 4-bit quantization (NF4 format)
- Gradient checkpointing
- Dynamic learning rate adjustment
- Early stopping with patience=3
- Adaptive batch processing
- Memory-efficient training with automated cleanup
### Model Architecture
- Base Architecture: LLaMA 3.1 8B Instruct
- Training Format: 4-bit quantization with double quantization
- Memory Efficient: Optimized for deployment with reduced memory footprint
## Intended Uses
This model is designed for:
- Generating Python code from natural language descriptions
- Assisting with code completion and suggestions
- Explaining Python concepts and best practices
- Helping with code debugging and optimization
- Supporting Python development tasks
## Training Data
The model was trained on a combination of:
1. 18,000 Python programming instructions and implementations from the Alpaca dataset
2. 25,000 Python code examples and explanations
## Performance and Limitations
### Strengths
- Specialized in Python programming tasks
- Memory-efficient implementation
- Trained with gradient stability monitoring
- Optimized for practical coding assistance
### Limitations
- Limited to Python programming language
- Based on LLaMA 3.1's knowledge cutoff
- May require context for complex programming tasks
## Usage Tips
To get the best results from this model:
1. Provide clear and specific instructions
2. Include relevant context when asking for code
3. Specify any particular Python version or library requirements
4. Mention any performance or style preferences
## Training Hardware Requirements
The model was trained using:
- GPU RTX4090 24GB VRAM
- CUDA compatibility
- Optimized for memory efficiency through 4-bit quantization
## License and Usage Rights
- Base model: LLaMA 3.1 license applies
- Additional training: [Specify your license]
## Citation and Contact
[christiannicoletti75@gmail.com] |