LVKinyanjui commited on
Commit
09b5d8c
1 Parent(s): f1ab738

Attempted to run a small llm

Browse files
Dockerfile CHANGED
@@ -42,8 +42,8 @@ RUN --mount=type=cache,target=/root/.cache/pip \
42
  # COPY requirements.txt .
43
  # RUN python -m pip install --no-cache-dir -r requirements.txt
44
 
45
- # Install ollama
46
- RUN curl -fsSL https://ollama.com/install.sh | sh
47
 
48
  # # Switch to the non-privileged user to run the application.
49
  # USER appuser
 
42
  # COPY requirements.txt .
43
  # RUN python -m pip install --no-cache-dir -r requirements.txt
44
 
45
+ # # Install ollama
46
+ # RUN curl -fsSL https://ollama.com/install.sh | sh
47
 
48
  # # Switch to the non-privileged user to run the application.
49
  # USER appuser
examples/{llm.py → llama3.py} RENAMED
File without changes
examples/phi3.py ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
3
+
4
+ torch.random.manual_seed(0)
5
+ model = AutoModelForCausalLM.from_pretrained(
6
+ "microsoft/Phi-3-mini-4k-instruct",
7
+ # device_map="auto",
8
+ torch_dtype="auto",
9
+ trust_remote_code=True,
10
+ )
11
+
12
+ tokenizer = AutoTokenizer.from_pretrained("microsoft/Phi-3-mini-4k-instruct")
13
+
14
+ messages = [
15
+ {"role": "system", "content": "You are a helpful AI assistant."},
16
+ {"role": "user", "content": "Can you provide ways to eat combinations of bananas and dragonfruits?"},
17
+ {"role": "assistant", "content": "Sure! Here are some ways to eat bananas and dragonfruits together: 1. Banana and dragonfruit smoothie: Blend bananas and dragonfruits together with some milk and honey. 2. Banana and dragonfruit salad: Mix sliced bananas and dragonfruits together with some lemon juice and honey."},
18
+ {"role": "user", "content": "What about solving an 2x + 3 = 7 equation?"},
19
+ ]
20
+
21
+ pipe = pipeline(
22
+ "text-generation",
23
+ model=model,
24
+ tokenizer=tokenizer,
25
+ )
26
+
27
+ generation_args = {
28
+ "max_new_tokens": 500,
29
+ "return_full_text": False,
30
+ "temperature": 0.0,
31
+ "do_sample": False,
32
+ }
33
+
34
+ output = pipe(messages, **generation_args)
35
+ print(output[0]['generated_text'])
requirements.txt CHANGED
@@ -2,4 +2,4 @@ chromadb==0.5.5
2
  pymupdf==1.24.9
3
  streamlit==1.38.0
4
  transformers
5
- torch
 
2
  pymupdf==1.24.9
3
  streamlit==1.38.0
4
  transformers
5
+ torch