ariG23498 HF Staff commited on
Commit
a891d98
·
verified ·
1 Parent(s): d82830a

Upload moonshotai_Kimi-K2-Instruct-0905_1.py with huggingface_hub

Browse files
moonshotai_Kimi-K2-Instruct-0905_1.py CHANGED
@@ -11,9 +11,14 @@
11
  # ///
12
 
13
  try:
14
- # Load model directly
15
- from transformers import AutoModelForCausalLM
16
- model = AutoModelForCausalLM.from_pretrained("moonshotai/Kimi-K2-Instruct-0905", trust_remote_code=True, torch_dtype="auto")
 
 
 
 
 
17
  with open('moonshotai_Kimi-K2-Instruct-0905_1.txt', 'w', encoding='utf-8') as f:
18
  f.write('Everything was good in moonshotai_Kimi-K2-Instruct-0905_1.txt')
19
  except Exception as e:
@@ -28,9 +33,14 @@ except Exception as e:
28
  with open('moonshotai_Kimi-K2-Instruct-0905_1.txt', 'a', encoding='utf-8') as f:
29
  import traceback
30
  f.write('''```CODE:
31
- # Load model directly
32
- from transformers import AutoModelForCausalLM
33
- model = AutoModelForCausalLM.from_pretrained("moonshotai/Kimi-K2-Instruct-0905", trust_remote_code=True, torch_dtype="auto")
 
 
 
 
 
34
  ```
35
 
36
  ERROR:
 
11
  # ///
12
 
13
  try:
14
+ # Use a pipeline as a high-level helper
15
+ from transformers import pipeline
16
+
17
+ pipe = pipeline("text-generation", model="moonshotai/Kimi-K2-Instruct-0905", trust_remote_code=True)
18
+ messages = [
19
+ {"role": "user", "content": "Who are you?"},
20
+ ]
21
+ pipe(messages)
22
  with open('moonshotai_Kimi-K2-Instruct-0905_1.txt', 'w', encoding='utf-8') as f:
23
  f.write('Everything was good in moonshotai_Kimi-K2-Instruct-0905_1.txt')
24
  except Exception as e:
 
33
  with open('moonshotai_Kimi-K2-Instruct-0905_1.txt', 'a', encoding='utf-8') as f:
34
  import traceback
35
  f.write('''```CODE:
36
+ # Use a pipeline as a high-level helper
37
+ from transformers import pipeline
38
+
39
+ pipe = pipeline("text-generation", model="moonshotai/Kimi-K2-Instruct-0905", trust_remote_code=True)
40
+ messages = [
41
+ {"role": "user", "content": "Who are you?"},
42
+ ]
43
+ pipe(messages)
44
  ```
45
 
46
  ERROR: