GGUF
conversational
kishida commited on
Commit
6a8a48e
·
verified ·
1 Parent(s): aa11504

readme追加

Browse files
Files changed (1) hide show
  1. README.md +61 -1
README.md CHANGED
@@ -4,4 +4,64 @@ datasets:
4
  - kishida/CompileError-Java-JP-cheerful
5
  base_model:
6
  - unsloth/Llama-3.2-3B-Instruct-GGUF
7
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  - kishida/CompileError-Java-JP-cheerful
5
  base_model:
6
  - unsloth/Llama-3.2-3B-Instruct-GGUF
7
+ ---
8
+
9
+ Javaのコンパイルエラーを明るく解説します。
10
+
11
+ ```python
12
+ from llama_cpp import Llama
13
+
14
+ # model load
15
+ base_model = "llama-3.2-3b"
16
+ quant = "Q4_K_M"
17
+ llm = Llama.from_pretrained(
18
+ repo_id=f"kishida/java-error-explainer-jp-cheerful-{base_model}",
19
+ filename=f"java-error-explainer-jp-cheerful-{base_model}.{quant}.gguf",
20
+ seed=1234,
21
+ )
22
+
23
+ # streaming
24
+ def chat(msg):
25
+ res = llm.create_chat_completion(
26
+ messages=[
27
+ {"role": "system", "content": "You are a Java compile error explainer."},
28
+ {"role": "user", "content": msg},
29
+ ],
30
+ temperature=0.7,
31
+ )
32
+ return res["choices"][0]["message"]["content"]
33
+
34
+ source = """
35
+ void main() {
36
+ IO.println(LocalDateTime.now());
37
+ IO.println("Hello")
38
+ }
39
+ """
40
+
41
+ error = """
42
+ HelloWithError.java:3: エラー: ';'がありません
43
+ IO.println("Hello")
44
+ ^
45
+ エラー1個
46
+ """
47
+
48
+ template = """
49
+ source:
50
+ {}
51
+
52
+ compile error:
53
+ {}
54
+ """
55
+
56
+ print("source + error")
57
+ print(chat(template.format(source, error)))
58
+ """
59
+ あら、コンパイルエラーの原因がわかってるね!3行目のIO.println("Hello")でセミコロンがついていないみたい。Javaでは文の最後に必ずセミコロンが必要なの。IO.println("Hello")っていう文の最後にセミコロンがついていないから、コンパイラが「え?ここで終わっちゃったの?」って混乱しちゃってる。IO.println("Hello")をIO.println("Hello");と書き換えれば解決するわ!
60
+ """
61
+
62
+ print("error only")
63
+ print(chat(error))
64
+ """
65
+ IO.println("Hello")って書いちゃってるけど、最後にセミコロンが必要なのよね。Javaは文末にセミコロンを必ず書き込まないとコンパイラーが「え?文の終わりに何があるの?」って混乱してるんだ。セミコロンを追加すれば問題なくなるから、ちゃんとJavaの基本ルールを覚えてみて!
66
+ """
67
+ ```