harshism1 commited on
Commit
f39237d
Β·
verified Β·
1 Parent(s): 0c3f702

create ReadMe.md

Browse files
Files changed (1) hide show
  1. README.md +97 -0
README.md ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ datasets:
3
+ - greengerong/leetcode
4
+ language:
5
+ - en
6
+ base_model:
7
+ - codellama/CodeLlama-7b-Instruct-hf
8
+ pipeline_tag: text2text-generation
9
+ ---
10
+
11
+ ## 🧠 Fine-tuned CodeLlama on LeetCode Problems
12
+
13
+ **This model is a fine-tuned version of [`codellama/CodeLlama-7b-Instruct-hf`](https://huggingface.co/codellama/CodeLlama-7b-Instruct-hf) on the [`greengerong/leetcode`](https://huggingface.co/datasets/greengerong/leetcode) dataset. It has been instruction-tuned to generate Python solutions from LeetCode-style problem descriptions.**
14
+ ---
15
+
16
+ ## πŸ“¦ Model Formats Available
17
+
18
+ - **Transformers-compatible (`.safetensors`)** β€” for use via πŸ€— Transformers.
19
+ - **GGUF (`.gguf`)** β€” for use via [llama.cpp](https://github.com/ggerganov/llama.cpp), including `llama-server`, `llama-cpp-python`, and other compatible tools.
20
+
21
+ ---
22
+
23
+ ## πŸ”— Example Usage (Transformers)
24
+
25
+ ```python
26
+ from transformers import AutoTokenizer, AutoModelForCausalLM, pipeline
27
+
28
+ model_id = "your-username/codellama-leetcode-finetuned"
29
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
30
+ model = AutoModelForCausalLM.from_pretrained(model_id)
31
+
32
+ pipe = pipeline("text-generation", model=model, tokenizer=tokenizer)
33
+
34
+ prompt = """You are an AI assistant. Solve the following problem:
35
+
36
+ Given an array of integers, return indices of the two numbers such that they add up to a specific target.
37
+
38
+ ## Solution
39
+ """
40
+
41
+ result = pipe(prompt, max_new_tokens=256, do_sample=True, temperature=0.7)
42
+ print(result[0]["generated_text"])
43
+ ```
44
+
45
+
46
+
47
+ ## βš™οΈ Usage with `llama.cpp`
48
+
49
+ You can run the model using tools in the [`llama.cpp`](https://github.com/ggerganov/llama.cpp) ecosystem. Make sure you have the `.gguf` version of the model (e.g., `codellama-leetcode.gguf`).
50
+
51
+ ### 🐍 Using `llama-cpp-python`
52
+
53
+ Install:
54
+
55
+ ```bash
56
+ pip install llama-cpp-python
57
+ ```
58
+ Then use:
59
+
60
+ ```
61
+ from llama_cpp import Llama
62
+
63
+ llm = Llama(
64
+ model_path="codellama-leetcode.gguf",
65
+ n_ctx=4096,
66
+ n_gpu_layers=99 # adjust based on your GPU
67
+ )
68
+
69
+ prompt = """### Problem
70
+ Given an array of integers, return indices of the two numbers such that they add up to a specific target.
71
+
72
+ ## Solution
73
+ """
74
+
75
+ output = llm(prompt, max_tokens=256)
76
+ print(output["choices"][0]["text"])
77
+ ```
78
+
79
+
80
+ ### πŸ–₯️ Using llama-server
81
+
82
+ Start the server:
83
+
84
+ ```
85
+ llama-server --model codellama-leetcode.gguf --port 8000 --n_gpu_layers 99
86
+ ```
87
+
88
+ Then send a request:
89
+
90
+ ```
91
+ curl http://localhost:8000/completion -d '{
92
+ "prompt": "### Problem\nGiven an array of integers...\n\n## Solution\n",
93
+ "n_predict": 256
94
+ }'
95
+ ```
96
+
97
+