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
Update README.md
Browse files
README.md
CHANGED
|
@@ -1,3 +1,93 @@
|
|
| 1 |
-
---
|
| 2 |
-
license: llama3.1
|
| 3 |
-
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: llama3.1
|
| 3 |
+
---
|
| 4 |
+
# Python Code Assistant based on LLaMA 3.1
|
| 5 |
+
|
| 6 |
+
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.
|
| 7 |
+
|
| 8 |
+
## Model Description
|
| 9 |
+
|
| 10 |
+
The model has been trained to assist with Python programming tasks through a progressive fine-tuning approach:
|
| 11 |
+
|
| 12 |
+
### First Training Stage
|
| 13 |
+
- Base Model: LLaMA 3.1 8B Instruct
|
| 14 |
+
- Dataset: [iamtarun/python_code_instructions_18k_alpaca](https://huggingface.co/datasets/iamtarun/python_code_instructions_18k_alpaca)
|
| 15 |
+
- Training Focus: Understanding Python programming instructions and generating appropriate code responses
|
| 16 |
+
|
| 17 |
+
### Second Training Stage
|
| 18 |
+
- Dataset: [flytech/python-codes-25k](https://huggingface.co/datasets/flytech/python-codes-25k)
|
| 19 |
+
- Focus: Enhancing code generation capabilities and understanding of advanced Python concepts
|
| 20 |
+
|
| 21 |
+
### Training Methodology
|
| 22 |
+
|
| 23 |
+
The model employs several advanced training techniques to ensure optimal performance:
|
| 24 |
+
|
| 25 |
+
- **LoRA Fine-tuning Parameters**:
|
| 26 |
+
- Rank (r): 8
|
| 27 |
+
- Alpha: 16
|
| 28 |
+
- Dropout: 0.1
|
| 29 |
+
- Target Modules: Query and Value Projections
|
| 30 |
+
|
| 31 |
+
- **Training Optimizations**:
|
| 32 |
+
- 4-bit quantization (NF4 format)
|
| 33 |
+
- Gradient checkpointing
|
| 34 |
+
- Dynamic learning rate adjustment
|
| 35 |
+
- Early stopping with patience=3
|
| 36 |
+
- Adaptive batch processing
|
| 37 |
+
- Memory-efficient training with automated cleanup
|
| 38 |
+
|
| 39 |
+
### Model Architecture
|
| 40 |
+
- Base Architecture: LLaMA 3.1 8B Instruct
|
| 41 |
+
- Training Format: 4-bit quantization with double quantization
|
| 42 |
+
- Memory Efficient: Optimized for deployment with reduced memory footprint
|
| 43 |
+
|
| 44 |
+
## Intended Uses
|
| 45 |
+
|
| 46 |
+
This model is designed for:
|
| 47 |
+
- Generating Python code from natural language descriptions
|
| 48 |
+
- Assisting with code completion and suggestions
|
| 49 |
+
- Explaining Python concepts and best practices
|
| 50 |
+
- Helping with code debugging and optimization
|
| 51 |
+
- Supporting Python development tasks
|
| 52 |
+
|
| 53 |
+
## Training Data
|
| 54 |
+
|
| 55 |
+
The model was trained on a combination of:
|
| 56 |
+
1. 18,000 Python programming instructions and implementations from the Alpaca dataset
|
| 57 |
+
2. 25,000 Python code examples and explanations
|
| 58 |
+
|
| 59 |
+
## Performance and Limitations
|
| 60 |
+
|
| 61 |
+
### Strengths
|
| 62 |
+
- Specialized in Python programming tasks
|
| 63 |
+
- Memory-efficient implementation
|
| 64 |
+
- Trained with gradient stability monitoring
|
| 65 |
+
- Optimized for practical coding assistance
|
| 66 |
+
|
| 67 |
+
### Limitations
|
| 68 |
+
- Limited to Python programming language
|
| 69 |
+
- Based on LLaMA 3.1's knowledge cutoff
|
| 70 |
+
- May require context for complex programming tasks
|
| 71 |
+
|
| 72 |
+
## Usage Tips
|
| 73 |
+
|
| 74 |
+
To get the best results from this model:
|
| 75 |
+
1. Provide clear and specific instructions
|
| 76 |
+
2. Include relevant context when asking for code
|
| 77 |
+
3. Specify any particular Python version or library requirements
|
| 78 |
+
4. Mention any performance or style preferences
|
| 79 |
+
|
| 80 |
+
## Training Hardware Requirements
|
| 81 |
+
|
| 82 |
+
The model was trained using:
|
| 83 |
+
- GPU with minimum 8GB VRAM
|
| 84 |
+
- CUDA compatibility
|
| 85 |
+
- Optimized for memory efficiency through 4-bit quantization
|
| 86 |
+
|
| 87 |
+
## License and Usage Rights
|
| 88 |
+
- Base model: LLaMA 3.1 license applies
|
| 89 |
+
- Additional training: [Specify your license]
|
| 90 |
+
|
| 91 |
+
## Citation and Contact
|
| 92 |
+
|
| 93 |
+
[Add your preferred citation format and contact information]
|