File size: 4,541 Bytes
6e914cf
 
 
9f895b6
6e914cf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9f895b6
6e914cf
 
 
 
 
 
 
 
 
 
 
 
 
9f895b6
6e914cf
 
 
 
 
 
 
 
 
 
bbb7699
6e914cf
 
 
 
 
 
 
 
9f895b6
 
 
6e914cf
 
 
 
79bfb83
6e914cf
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
import argparse
import json

import gradio as gr
import requests


def http_bot(prompt, history):
    headers = {"User-Agent": "vLLM Client"}
    pload = {
        "prompt": f"""You are SEMIKONG, an AI Assistant developed by the AI Alliance.
Your role is to use your's in-depth knowledge in the field of Semiconductor Manufacturing Process to answer the instruction from the user in the most sophisticate, detail and technical ways.
You must use as much as technical term as possible to make the answer more professional and informative.
Your answer must align with these criteria:
1. Clarity and Structure: Assess the logical structure and clarity of the presentation. Determine if the answer is organized in a way that makes it easy to follow and understand, regardless of the question's complexity.
2. Accuracy and Depth of Knowledge: Evaluate the technical accuracy and depth of knowledge demonstrated in the answer. Check for precision and correctness in the information provided, ensuring it aligns with established principles and facts.
3. Precision in Terminology: Review the use of terminology within the answer. Ensure that terms are used precisely and specifically, enhancing the accuracy and professionalism of the response.
4. Causality and Correlation: Analyze the identification and explanation of causal relationships or correlations. This is crucial for effectively diagnosing problems, analyzing scenarios, and discussing theoretical principles.
5. Practicality and Applicability: Judge the practicality and applicability of the recommendations and solutions offered. Ensure they are tailored to the specific conditions of the question and are feasible in the given context.
6. Comprehensive Coverage: Verify that the answer addresses all relevant aspects of the question. The response should be thorough, covering multiple angles and potential outcomes suitable for the type of question asked.
7. Relevance to the Question: Confirm that the content of the answer directly addresses the core of the question. All explanations and solutions should be relevant and specifically tailored to the details and constraints of the question.
Now given an instruction from : {prompt}.
Your answer: <your answer here>
        """,
        "stream": True,
        "max_tokens": 1024,
        "temperature": 0.0,
        "presence_penalty": 0.7,
        "frequency_penalty": 0.5,
        "repetition_penalty": 1.0,
        "length_penalty": 1.0,
        "top_p": 1.0,
        "top_k": 50,
        "min_p": 0.8,
        "n": 1,
        "best_of": 1,
        "use_beam_search": False,
        "early_stopping": False,
    }
    response = requests.post(args.model_url, headers=headers, json=pload, stream=True)

    for chunk in response.iter_lines(
        chunk_size=8192, decode_unicode=False, delimiter=b"\0"
    ):
        if chunk:
            data = json.loads(chunk.decode("utf-8"))
            output = data["text"][0]
            output_clean = output.split("<your answer here>")[-1]
            yield output_clean


def build_demo():
    demo = gr.ChatInterface(
        http_bot,
        chatbot=gr.Chatbot(height=500),
        textbox=gr.Textbox(
            placeholder="Ask SEMIKONG something", container=False, scale=7
        ),
        title="SEMIKONG - Foundation Model for Semiconductor Industry",
        description="""SEMIKONG is the first Open-Source Foundation Model supporting the Semiconductor Manufacturing Industry.\n
This is the result of the collaboration between AItomatic, FPT AI Center and Tokyo Electron with the supported from the AI Alliance and IBM.\n
For technical report, please refer to: __TBA__ \n
For open-source repository, please refer to: __TBA__
""",
        theme="soft",
        examples=[
            "Describe different type of etching in semiconductor manufacturing process",
            "What is Photolithography ?",
            "Describe in detail about PVD, CVD, and ALD and their role in semiconductor manufacturing",
            "What elements are necessary for miniaturization of semiconductor etch manufacturing equipment and what are their priorities?",
        ],
        cache_examples=True,
        retry_btn=None,
        undo_btn="Delete Previous",
        clear_btn="Clear",
    )
    return demo


if __name__ == "__main__":
    parser = argparse.ArgumentParser()
    parser.add_argument(
        "--model-url",
        type=str,
        default="http://35.197.41.208:8000/generate",
    )
    args = parser.parse_args()

    demo = build_demo()
    demo.queue().launch()