Markndrei commited on
Commit
25f4535
Β·
1 Parent(s): 25ff1f5

Improved Documentation using expanders and streamlit text formatting features.

Browse files
Files changed (1) hide show
  1. app.py +40 -27
app.py CHANGED
@@ -7,33 +7,46 @@ client = OpenAI(
7
  base_url="https://integrate.api.nvidia.com/v1",
8
  api_key=os.environ.get("NVIDIA_API_KEY")
9
  )
10
- """
11
- Parameters for Response Specification Features:
12
- - model: The AI model to use for generating responses.
13
- - temperature: Controls the randomness of the response. Higher values result in more randomness.
14
- Example Use Cases for this one:
15
- - 0.0: Always the same response
16
- - 0.1 - 0.3: Mostly Deterministic, Factual and repetitive siya.
17
- - 0.4 - 0.7: Balanced between coherence and creative responses ni.
18
- - 0.8 - 1.0: More creative and imaginative responses[less coherent].
19
- - max_tokens: The maximum number of tokens(words/subwords) to generate in the response.
20
- - top_p: Controls the probability of sampling from the top tokens. Higher values result in more creativity. [This is related to the temperature parameter]
21
- -This is also known as nucleus sampling, determining the probability of nexty words the AI will consider
22
- The higher the value, the more diverse the response will be.
23
- For example bala:
24
- top_p + low temp = more accurate and factual responses
25
- top_p + high temp = more creative responses, unexpected responses siya bih.
26
- - num_responses: The number of responses to generate.
27
- - fact_check: If True, the AI will check the factual accuracy of the response.
28
- If False, the AI will prioritize creativity over factual accuracy.
29
-
30
- IN SUMMARY:
31
- - temperature controls creativity vs accuracy.
32
- - max_tokens affects length.
33
- - top_p fine-tunes word diversity.
34
- - fact_check ensures factual correctness (but slightly limits fluency).
35
- - num_responses generates different variations of the same prompt.
36
- """
 
 
 
 
 
 
 
 
 
 
 
 
 
37
 
38
  def query_ai_model(prompt, model="meta/llama-3.1-405b-instruct", temperature=0.7, max_tokens=512, top_p=0.9, fact_check=False, num_responses=1):
39
  responses = []
 
7
  base_url="https://integrate.api.nvidia.com/v1",
8
  api_key=os.environ.get("NVIDIA_API_KEY")
9
  )
10
+ st.markdown("## πŸ› οΈ Response Specification Features")
11
+ st.markdown("**The expanders below are parameters that you can adjust to customize the AI response.**")
12
+ with st.expander("πŸ“Œ **Model Selection**"):
13
+ st.write("Choose the AI model to generate responses.")
14
+
15
+ with st.expander("🎨 **Temperature (Creativity Control)**"):
16
+ st.write("""
17
+ - **0.0**: Always the same response (deterministic).
18
+ - **0.1 - 0.3**: Mostly factual and repetitive.
19
+ - **0.4 - 0.7**: Balanced between coherence and creativity.
20
+ - **0.8 - 1.0**: Highly creative but less predictable.
21
+ """)
22
+
23
+ with st.expander("πŸ“ **Max Tokens (Response Length)**"):
24
+ st.write("Defines the maximum number of words/subwords in the response.")
25
+
26
+ with st.expander("🎯 **Top-p (Nucleus Sampling)**"):
27
+ st.write("""
28
+ Controls word diversity by sampling from top-probability tokens:
29
+ - **High `top_p` + Low `temperature`** β†’ More factual, structured responses.
30
+ - **High `top_p` + High `temperature`** β†’ More diverse, unexpected responses.
31
+ """)
32
+
33
+ with st.expander("πŸ”„ **Number of Responses**"):
34
+ st.write("Specifies how many response variations the AI should generate.")
35
+
36
+ with st.expander("βœ… **Fact-Checking**"):
37
+ st.write("""
38
+ - If **enabled**, AI prioritizes factual accuracy.
39
+ - If **disabled**, AI prioritizes creativity.
40
+ """)
41
+
42
+ st.markdown("""
43
+ ### πŸ”Ž **Summary**
44
+ - `temperature` β†’ Adjusts **creativity vs accuracy**.
45
+ - `max_tokens` β†’ Defines **response length**.
46
+ - `top_p` β†’ Fine-tunes **word diversity**.
47
+ - `fact_check` β†’ Ensures **factual correctness** (but may reduce fluency).
48
+ - `num_responses` β†’ Generates **different variations** of the same prompt.
49
+ """)
50
 
51
  def query_ai_model(prompt, model="meta/llama-3.1-405b-instruct", temperature=0.7, max_tokens=512, top_p=0.9, fact_check=False, num_responses=1):
52
  responses = []