karthik18AI commited on
Commit
2dad249
·
verified ·
1 Parent(s): e41074a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -8
app.py CHANGED
@@ -1,8 +1,20 @@
1
- # Use a pipeline as a high-level helper
2
- from transformers import pipeline
3
-
4
- messages = [
5
- {"role": "user", "content": "Give a addition of two numbers code in c#?"},
6
- ]
7
- pipe = pipeline("text-generation", model="Mxode/minicoder-7M-init",max_new_tokens=100)
8
- pipe(messages)
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import AutoModelForCausalLM, AutoTokenizer
2
+
3
+ # Load the MobiLlama model and tokenizer
4
+ model_name = "MBZUAI/MobiLlama-05B"
5
+ model = AutoModelForCausalLM.from_pretrained(model_name)
6
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
7
+
8
+ # Example C# code snippet
9
+ code_snippet_csharp = """
10
+ public int Add(int a, int b) {
11
+ return a + b;
12
+ }
13
+ """
14
+
15
+ # Tokenize and generate summary
16
+ inputs = tokenizer(code_snippet_csharp, return_tensors="pt")
17
+ outputs = model.generate(inputs.input_ids, max_length=50)
18
+ summary = tokenizer.decode(outputs[0], skip_special_tokens=True)
19
+
20
+ print("C# Code Summary:", summary)