File size: 2,453 Bytes
d07b421
 
 
 
 
82b0b34
81bed86
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
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.
- The daily limit is 50 requests per IP address. If you need more, please contact us.
- This demo uses an API-based implementation of the nudging, which can be slow due to multiple API calls for each question. With a proper speculative decoding type implementation, the inference speed of nudging can be significantly improved.
"""

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',
]

custom_css = """
.chatbot mark {
    background-color: yellow;
    color: orange;
    font-style: italic;
    font-weight: bold;
}
"""