File size: 2,773 Bytes
d07b421
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
HEADER_MD = """# Inference-time Alignment with Nudging.
[๐Ÿ“‘ Paper](https://arxiv.org/abs/2410.09300) | [๐Ÿ›œ Website](https://fywalter.github.io/nudging/) | [๐Ÿ’ป GitHub](https://github.com/fywalter/nudging) | [๐Ÿฆ X](https://x.com/Walter_Fei/status/1848538273917898753) | ๐Ÿ“ฎ Contact: [Yu Fei](https://fywalter.github.io/)

**By injecting a few nudging tokens at inference time, we can make base models able to follow user instructions helpfully and safely.** 
- Our demo is powered by the [Together AI API](https://api.together.ai/). However, since only three base models are currently still available in the serverless API, we only choose three base models and nudging models for demonstration.
"""

js_code_label = """
function addApiKeyLink() {
    // Select the div with id 'api_key'
    const apiKeyDiv = document.getElementById('api_key');
    // Find the span within that div with data-testid 'block-info'
    const blockInfoSpan = apiKeyDiv.querySelector('span[data-testid="block-info"]');
    // Create the new link element
    const newLink = document.createElement('a');
    newLink.href = 'https://api.together.ai/settings/api-keys';
    newLink.textContent = ' View your keys here.';
    newLink.target = '_blank'; // Open link in new tab
    newLink.style = 'color: #007bff; text-decoration: underline;';
    // Create the additional text
    const additionalText = document.createTextNode(' (new account will have free credits to use.)');
    // Append the link and additional text to the span
    if (blockInfoSpan) {
        // add a br 
        apiKeyDiv.appendChild(document.createElement('br'));
        apiKeyDiv.appendChild(newLink);
        apiKeyDiv.appendChild(additionalText);
    } else {
        console.error('Span with data-testid "block-info" not found');
    }
}
"""

BASE_MODELS = [
    "Llama-2-70B",
    "Mistral-7B-v0.1",
    "Mixtral-8x7B-v0.1",
]

NUDGING_MODELS = [
    'Llama-2-13B-chat',
    'Gemma-2-2B-it',
    'Mistral-7B-v0.1-Instruct',
]


my_css = """
/* CSS for a link color that is visible on both black and white backgrounds */
a {
    color: #1E90FF; /* DodgerBlue */
    text-decoration: none; /* Optional: remove underline */
}
a:hover {
    color: #104E8B; /* Slightly darker blue for hover effect */
    text-decoration: underline; /* Optional: add underline on hover */
}
"""
# import json 
# with open("together_model_ids.json", "r") as f:
#     TOGETHER_MODEL_IDS = json.load(f)

# for _, model_id in MODEL_MAPPING.items():
#     if model_id not in TOGETHER_MODEL_IDS + HYPERBOLIC_MODELS:
#         print(model_id)

# Custom CSS for highlighting nudging words in the Chatbot
custom_css = """
.chatbot mark {
    background-color: yellow;
    color: orange;
    font-style: italic;
    font-weight: bold;
}
"""