IlyaGusev / saiga2_70b_lora

huggingface.co
Total runs: 0
24-hour runs: 0
7-day runs: 0
30-day runs: 0
Model's Last Updated: October 10 2023
text-generation

Introduction of saiga2_70b_lora

Model Details of saiga2_70b_lora

Saiga2 70B, Russian LLaMA2-based chatbot

Based on LLaMA-2 70B fp16

Llama.cpp version: link

This is an adapter-only version.

Training code: link

WARNING : Avoid using V100 (in Colab, for example). Outputs are much worse in this case.

from peft import PeftModel, PeftConfig
from transformers import AutoModelForCausalLM, AutoTokenizer, GenerationConfig

MODEL_NAME = "IlyaGusev/saiga2_70b_lora"
DEFAULT_MESSAGE_TEMPLATE = "<s>{role}\n{content}</s>\n"
DEFAULT_SYSTEM_PROMPT = "Ты — Сайга, русскоязычный автоматический ассистент. Ты разговариваешь с людьми и помогаешь им."

class Conversation:
    def __init__(
        self,
        message_template=DEFAULT_MESSAGE_TEMPLATE,
        system_prompt=DEFAULT_SYSTEM_PROMPT,
        start_token_id=1,
        bot_token_id=9225
    ):
        self.message_template = message_template
        self.start_token_id = start_token_id
        self.bot_token_id = bot_token_id
        self.messages = [{
            "role": "system",
            "content": system_prompt
        }]

    def get_start_token_id(self):
        return self.start_token_id

    def get_bot_token_id(self):
        return self.bot_token_id

    def add_user_message(self, message):
        self.messages.append({
            "role": "user",
            "content": message
        })

    def add_bot_message(self, message):
        self.messages.append({
            "role": "bot",
            "content": message
        })

    def get_prompt(self, tokenizer):
        final_text = ""
        for message in self.messages:
            message_text = self.message_template.format(**message)
            final_text += message_text
        final_text += tokenizer.decode([self.start_token_id, self.bot_token_id])
        return final_text.strip()


def generate(model, tokenizer, prompt, generation_config):
    data = tokenizer(prompt, return_tensors="pt")
    data = {k: v.to(model.device) for k, v in data.items()}
    output_ids = model.generate(
        **data,
        generation_config=generation_config
    )[0]
    output_ids = output_ids[len(data["input_ids"][0]):]
    output = tokenizer.decode(output_ids, skip_special_tokens=True)
    return output.strip()

config = PeftConfig.from_pretrained(MODEL_NAME)
model = AutoModelForCausalLM.from_pretrained(
    config.base_model_name_or_path,
    load_in_8bit=True,
    torch_dtype=torch.float16,
    device_map="auto"
)
model = PeftModel.from_pretrained(
    model,
    MODEL_NAME,
    torch_dtype=torch.float16
)
model.eval()

tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME, use_fast=False)
generation_config = GenerationConfig.from_pretrained(MODEL_NAME)
print(generation_config)

inputs = ["Почему трава зеленая?", "Сочини длинный рассказ, обязательно упоминая следующие объекты. Дано: Таня, мяч"]
for inp in inputs:
    conversation = Conversation()
    conversation.add_user_message(inp)
    prompt = conversation.get_prompt(tokenizer)

    output = generate(model, tokenizer, prompt, generation_config)
    print(inp)
    print(output)
    print()
    print("==============================")
    print()

Examples:

User: Почему трава зеленая? 
Saiga: 
User: Сочини длинный рассказ, обязательно упоминая следующие объекты. Дано: Таня, мяч
Saiga:

v1:

  • dataset code revision 0dbd022613874fcda915f588f4a3292e137017d2
  • wandb link
  • 5 datasets: ru_turbo_alpaca, ru_sharegpt_cleaned, oasst1_ru_main_branch, gpt_roleplay_realm, ru_instruct_gpt4
  • Datasets merging script: create_chat_set.py
  • saiga2_70b vs gpt-3.5-turbo: 91-10-75

Runs of IlyaGusev saiga2_70b_lora on huggingface.co

0
Total runs
0
24-hour runs
0
3-day runs
0
7-day runs
0
30-day runs

More Information About saiga2_70b_lora huggingface.co Model

More saiga2_70b_lora license Visit here:

https://choosealicense.com/licenses/cc-by-4.0

saiga2_70b_lora huggingface.co

saiga2_70b_lora huggingface.co is an AI model on huggingface.co that provides saiga2_70b_lora's model effect (), which can be used instantly with this IlyaGusev saiga2_70b_lora model. huggingface.co supports a free trial of the saiga2_70b_lora model, and also provides paid use of the saiga2_70b_lora. Support call saiga2_70b_lora model through api, including Node.js, Python, http.

saiga2_70b_lora huggingface.co Url

https://huggingface.co/IlyaGusev/saiga2_70b_lora

IlyaGusev saiga2_70b_lora online free

saiga2_70b_lora huggingface.co is an online trial and call api platform, which integrates saiga2_70b_lora's modeling effects, including api services, and provides a free online trial of saiga2_70b_lora, you can try saiga2_70b_lora online for free by clicking the link below.

IlyaGusev saiga2_70b_lora online free url in huggingface.co:

https://huggingface.co/IlyaGusev/saiga2_70b_lora

saiga2_70b_lora install

saiga2_70b_lora is an open source model from GitHub that offers a free installation service, and any user can find saiga2_70b_lora on GitHub to install. At the same time, huggingface.co provides the effect of saiga2_70b_lora install, users can directly use saiga2_70b_lora installed effect in huggingface.co for debugging and trial. It also supports api for free installation.

saiga2_70b_lora install url in huggingface.co:

https://huggingface.co/IlyaGusev/saiga2_70b_lora

Url of saiga2_70b_lora

saiga2_70b_lora huggingface.co Url

Provider of saiga2_70b_lora huggingface.co

IlyaGusev
ORGANIZATIONS

Other API from IlyaGusev

huggingface.co

Total runs: 6
Run Growth: 6
Growth Rate: 100.00%
Updated: December 12 2024
huggingface.co

Total runs: 4
Run Growth: -6
Growth Rate: -150.00%
Updated: July 13 2022