Spaces:
Running
Running
| 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. | |
| - [Update] Unfortunately, Together AI has stopped serving most base models and many small instruct models. The current demo only supports nudging LLama-2-70B with Mistral-7B-v0.1-Instruct. Still, you can run nudging locally with any model pairs using our code. | |
| - 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; | |
| } | |
| """ |