sh install-docker.sh
- log out
- log back in
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: https://gist.github.com/jneuff/682d47b786329f19291d166957b3274a | |
/// Fix a huggingface tokenizer to which tokens have been added after training. | |
/// | |
/// Adding tokens after training via `add_special_tokens` leads to them being added to the | |
/// `added_tokens` section but not to the `model.vocab` section. This yields warnings like: | |
/// ``` | |
/// [2023-10-17T07:54:05Z WARN tokenizers::tokenizer::serialization] Warning: Token '<|empty_usable_token_space_1023|>' was expected to have ID '129023' but was given ID 'None' | |
/// ``` |
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 | |
#SBATCH --job-name=llm-swarm | |
#SBATCH --partition hopper-prod | |
#SBATCH --gpus={{gpus}} | |
#SBATCH --cpus-per-task=12 | |
#SBATCH --mem-per-cpu=11G | |
#SBATCH -o slurm/logs/%x_%j.out | |
# See original source here: | |
# https://github.com/huggingface/llm-swarm/blob/main/templates/tgi_h100.template.slurm |
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 typing as t | |
import jsonlines | |
from langchain.schema import Document | |
def save_docs_to_jsonl(documents: t.Iterable[Document], file_path: str) -> None: | |
with jsonlines.open(file_path, mode="w") as writer: | |
for doc in documents: | |
writer.write(doc.dict()) |
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
""" | |
# See https://huggingface.co/intfloat/e5-mistral-7b-instruct for model inference code | |
## Quickstart | |
Install requirements | |
```bash | |
pip install fastapi uvicorn torch 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
# TODO: Add this to PR for Langchain so that it will be easy to use across all our different LLM projects | |
import re | |
import time | |
import warnings | |
from pathlib import Path | |
from typing import List, Union, Optional | |
import requests | |
from tqdm import tqdm | |
from pydantic import BaseModel, Field, field_validator, computed_field |
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 os | |
from typing import List, Union | |
def listdirs(path, extensions: Union[List[str], str] = None): | |
""" List all files in directory (including walking all subdirectories). | |
Can filter by file extension by providing either, for example: | |
extensions='png' | |
extensions=['png', 'jpeg'] |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
# Uses python3 | |
import sys | |
from typing import List | |
def calc_fib(n): | |
if n == 1 or n == 2: | |
return 1 | |
elif n == 0: | |
return 0 |
NewerOlder