ardavey commited on
Commit
914a10c
·
verified ·
1 Parent(s): c112989

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +148 -0
README.md CHANGED
@@ -0,0 +1,148 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Model: Llama-3.1-70B-Instruct
2
+
3
+ Model ini adalah model instruksi yang telah difinetuned dan dievaluasi untuk menghasilkan catatan, flashcards, dan kuis berdasarkan konten yang diberikan. Model ini menggunakan Hugging Face API dengan fine-grained token untuk mengakses model.
4
+
5
+ ## Cara Menggunakan Model
6
+
7
+ ### 1. Python
8
+
9
+ Berikut adalah contoh kode Python untuk menggunakan model ini:
10
+
11
+ ```python
12
+ from openai import OpenAI
13
+ from IPython.display import display, Markdown
14
+
15
+ client = OpenAI(
16
+ api_key="hf_xxxxxxxxxxxxxxx", # isi dengan token "FINE GRAINED" huggingface anda!
17
+ base_url="https://huggingface.co/api/integrations/dgx/v1",
18
+ )
19
+
20
+ # System prompts - pastikan ini sudah didefinisikan
21
+ notes_prompt = "..." // wajib isi dengan prompt notes yang sudah ditentukan (notes_prompt.txt)
22
+ flashcards_prompt = "..." // wajib isi dengan prompt flashcards yang sudah ditentukan (flashcards_prompt.txt)
23
+ quiz_prompt = "..." // wajib isi dengan prompt quiz yang sudah ditentukan (quiz_prompt.txt)
24
+
25
+ content = "..." // isi dengan dokumen yang sudah di ekstrak dari si parser (PDF, TXT, DOCX)
26
+
27
+
28
+ # 1. Generate notes
29
+ notes_response = client.chat.completions.create(
30
+ model="meta-llama/Llama-3.1-70B-Instruct",
31
+ messages=[
32
+ {"role": "system", "content": notes_prompt},
33
+ {"role": "user", "content": content},
34
+ ],
35
+ temperature=0.3,
36
+ max_tokens=10_000
37
+ )
38
+
39
+ # Notes response
40
+ notes_md = notes_response.choices[0].message.content
41
+
42
+ # 2. Generate flashcards
43
+ flashcards_response = client.chat.completions.create(
44
+ model="meta-llama/Llama-3.1-70B-Instruct",
45
+ messages=[
46
+ {"role": "system", "content": flashcards_prompt},
47
+ {"role": "user", "content": notes_md},
48
+ ],
49
+ temperature=0.3,
50
+ max_tokens=1024
51
+ )
52
+
53
+ # flashcards response
54
+ flashcards_md = flashcards_response.choices[0].message.content
55
+
56
+ # 3. Generate quiz
57
+ quiz_response = client.chat.completions.create(
58
+ model="meta-llama/Llama-3.1-70B-Instruct",
59
+ messages=[
60
+ {"role": "system", "content": quiz_prompt},
61
+ {"role": "user", "content": notes_md},
62
+ ],
63
+ temperature=0.3,
64
+ max_tokens=5048
65
+ )
66
+
67
+ # Quiz response
68
+ quiz_md = quiz_response.choices[0].message.content
69
+
70
+ print(notes_md)
71
+ print(flashcards_md)
72
+ print(quiz_md)
73
+ ```
74
+
75
+ ### 2. Javascript
76
+ ```javascript
77
+ import { HfInference } from "@huggingface/inference";
78
+
79
+ const client = new HfInference("hf_xxxxxxxxxxxxxxx"); // isi dengan token "FINE GRAINED" huggingface anda!
80
+
81
+ // System prompts - pastikan ini sudah didefinisikan
82
+ const notes_prompt = "..." // wajib isi dengan prompt notes yang sudah ditentukan (notes_prompt.txt)
83
+ const flashcards_prompt = "..." // wajib isi dengan prompt flashcards yang sudah ditentukan (flashcards_prompt.txt)
84
+ const quiz_prompt = "..." // wajib isi dengan prompt quiz yang sudah ditentukan (quiz_prompt.txt)
85
+
86
+
87
+ const content = "..." // isi dengan dokumen yang sudah di ekstrak dari si parser (PDF, TXT, DOCX)
88
+
89
+ async function generateEducationalContent() {
90
+ try {
91
+ // 1. Generate Notes
92
+ const notesResponse = await client.chatCompletion({
93
+ model: "meta-llama/Llama-3.1-70B-Instruct",
94
+ messages: [
95
+ { role: "system", content: notes_prompt },
96
+ { role: "user", content: content }
97
+ ],
98
+ temperature: 0.3,
99
+ max_tokens: 10_000
100
+ });
101
+
102
+ const notesMd = notesResponse.choices[0].message.content;
103
+ console.log("=== CATATAN ===");
104
+ console.log(notesMd);
105
+
106
+ // 2. Generate Flashcards
107
+ const flashcardsResponse = await client.chatCompletion({
108
+ model: "meta-llama/Llama-3.1-70B-Instruct",
109
+ messages: [
110
+ { role: "system", content: flashcards_prompt },
111
+ { role: "user", content: notesMd }
112
+ ],
113
+ temperature: 0.3,
114
+ max_tokens: 1024
115
+ });
116
+
117
+ const flashcardsMd = flashcardsResponse.choices[0].message.content;
118
+ console.log("\n=== FLASHCARDS ===");
119
+ console.log(flashcardsMd);
120
+
121
+ // 3. Generate Quiz
122
+ const quizResponse = await client.chatCompletion({
123
+ model: "meta-llama/Llama-3.1-70B-Instruct",
124
+ messages: [
125
+ { role: "system", content: quiz_prompt },
126
+ { role: "user", content: notesMd }
127
+ ],
128
+ temperature: 0.3,
129
+ max_tokens: 5048
130
+ });
131
+
132
+ const quizMd = quizResponse.choices[0].message.content;
133
+ console.log("\n=== KUIS ===");
134
+ console.log(quizMd);
135
+
136
+ } catch (error) {
137
+ console.error("Error:", error);
138
+ }
139
+ }
140
+
141
+ // Eksekusi fungsi utama
142
+ generateEducationalContent();
143
+ ```
144
+
145
+ Pastikan anda menginstall dependency yang diperlukan:
146
+ ```node.js
147
+ npm install @huggingface/inference
148
+ ```