This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import Dict, List | |
import torch | |
from transformers import AutoModelForSequenceClassification, AutoTokenizer | |
class ArmoRMPipeline: | |
def __init__(self, model_id, device_map="auto", torch_dtype=torch.bfloat16, truncation=True, trust_remote_code=False, max_length=4096): | |
self.model = AutoModelForSequenceClassification.from_pretrained( | |
model_id, | |
device_map=device_map, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests as r | |
from huggingface_hub import HfFolder | |
from tqdm import tqdm | |
from datasets import Dataset | |
headers = {"Authorization": f"Bearer {HfFolder.get_token()}"} | |
sess = r.Session() | |
sess.headers.update(headers) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
start=$(date +%s) | |
# Initialize RESULT_DIRECTORY with default value and HF_MODEL_ID with an empty string | |
RESULT_DIRECTORY="nous" | |
HF_MODEL_ID="" | |
TRUST_REMOTE_CODE="False" | |
CURRENT_DIR=$(pwd) | |
# List of Benchmarking Tasks |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from openai import OpenAI | |
# initialize the client but point it to TGI | |
client = OpenAI( | |
base_url="https://api-inference.huggingface.co/v1", | |
api_key="hf_xxx" # Replace with your token | |
) | |
chat_completion = client.chat.completions.create( | |
model="google/gemma-7b-it", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
torchrun --nnodes 2 --nproc_per_node 32 --master_addr algo-1 --master_port 7777 --node_rank 0 train_llama.py \ | |
--model_id "meta-llama/Llama-2-70b-hf" \ | |
--lr 5e-5 \ | |
--per_device_train_batch_size 16 \ | |
--bf16 True \ | |
--epochs 3 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
cli_output = ''' | |
Text Generation Launcher | |
Usage: text-generation-launcher [OPTIONS] | |
Options: | |
--model-id <MODEL_ID> | |
The name of the model to load. Can be a MODEL_ID as listed on <https://hf.co/models> like `gpt2` or `OpenAssistant/oasst-sft-1-pythia-12b`. Or it can be a local directory containing the necessary files as saved by `save_pretrained(...)` methods of transformers |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Nuremberg (/ˈnjʊərəmbɜːrɡ/ NURE-əm-burg; German: Nürnberg [ˈnʏʁnbɛʁk] (listen); in the local East Franconian dialect: Nämberch [ˈnɛmbɛrç]) is the second-largest city of the German state of Bavaria after its capital Munich, and its 541.000 inhabitants[3] make it the 14th-largest city in Germany. On the Pegnitz River (from its confluence with the Rednitz in Fürth onwards: Regnitz, a tributary of the River Main) and the Rhine–Main–Danube Canal, it lies in the Bavarian administrative region of Middle Franconia, and is the largest city and the unofficial capital of Franconia. Nuremberg forms with the neighbouring cities of Fürth, Erlangen and Schwabach a continuous conurbation with a total population of 800,376 (2019), which is the heart of the urban area region with around 1.4 million inhabitants,[4] while the larger Nuremberg Metropolitan Region has approximately 3.6 million inhabitants. The city lies about 170 kilometres (110 mi) north of Munich. It is the largest city in the East Franconian dialect area (collo |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
B_INST, E_INST = "[INST]", "[/INST]" | |
B_SYS, E_SYS = "<<SYS>>\n", "\n<</SYS>>\n\n" | |
SYSTEM= """\ | |
You are a helpful, respectful and honest assistant. Always answer as helpfully as possible, while being safe. Your answers should not include any harmful, unethical, racist, sexist, toxic, dangerous, or illegal content. Please ensure that your responses are socially unbiased and positive in nature. | |
If a question does not make any sense, or is not factually coherent, explain why instead of answering something not correct. If you don't know the answer to a question, please don't share false information.""" | |
INSTRUCTION="What is the receipe of mayonnaise?" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SOURCE: | |
- [1](https://react.dev/learn/writing-markup-with-jsx) | |
JSX is a syntax extension for JavaScript that lets you write HTML-like markup inside a JavaScript file. Although there are other ways to write components, most React developers prefer the conciseness of JSX, and most codebases use it. | |
- [2](https://react.dev/learn/writing-markup-with-jsx#jsx-putting-markup-into-javascript) | |
The Web has been built on HTML, CSS, and JavaScript. For many years, web developers kept content in HTML, design in CSS, and logic in JavaScript—often in separate files! Content was marked up inside HTML while the page’s logic lived separately in JavaScript. JSX and React are two separate things. They’re often used together, but you can use them independently of each other. JSX is a syntax extension, while React is a JavaScript library. | |
QUESTION: Do I need to use JSX with React? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
JSX is a syntax extension for JavaScript that lets you write HTML-like markup inside a JavaScript file. Although there are other ways to write components, most React developers prefer the conciseness of JSX, and most codebases use it. | |
You will learn | |
Why React mixes markup with rendering logic | |
How JSX is different from HTML | |
How to display information with JSX | |
JSX: Putting markup into JavaScript | |
The Web has been built on HTML, CSS, and JavaScript. For many years, web developers kept content in HTML, design in CSS, and logic in JavaScript—often in separate files! Content was marked up inside HTML while the page’s logic lived separately in JavaScript: | |
HTML markup with purple background and a div with two child tags: p and form. |