/ Модель

Характеристики

Контекст
2 048 токенов
Лицензия
MIT
Архитектура
phi-msft · MoE
Опубликована
7 янв 2024

phixtral-2x2_8

Генерация текстаТекст → текст11 профессий
214скачиваний за 30 дней150лайковвеса обновлены14 янв 2024

Описание модели

Составлено на русском по карточке модели и метаданным Hugging Face

MoE-модель на основе двух Phi-2 для генерации английского текста, диалогов и кода.

phixtral-2x2_8 — языковая модель с архитектурой Mixture of Experts, созданная Mlabonne из двух моделей Microsoft Phi-2. Она объединяет cognitivecomputations/dolphin-2_6-phi-2 и lxuechen/phi-2-dpo с помощью модифицированной версии mergekit и вдохновлена архитектурой Mixtral-8x7B. Автор сообщает, что модель превосходит каждого из отдельных экспертов; в README также приведены результаты оценки на наборе Nous suite.

Модель предназначена для генерации текста в диалогах и задач с кодом. Она принимает текст и генерирует текст, поддерживает английский язык и имеет контекстное окно 2048 токенов. Репозиторий содержит веса в формате safetensors; указана лицензия MIT. Для модели предлагается запуск в 4-битной точности на GPU T4.

Сценарии применения

  • генерация ответов в диалоге на английском языке
  • написание и дополнение кода
  • ответы на вопросы общего характера
  • сравнение результатов языковых моделей на бенчмарках

Ограничения

Контекстное окно ограничено 2048 токенами. Результаты бенчмарков приведены автором; независимая оценка в карточке не описана.

Публичные бенчмарки

Результаты из открытых лидербордов в сравнении с лидерами каталога

Для каких профессий подходит11

Разделы каталога профессий, в задачах которых используется эта модель

Все профессии

Также подходит для

Карточка модели

README от автора на Hugging Face, как он его опубликовал

Открыть на Hugging Face

phixtral-2x2_8

phixtral-2x2_8 is the first Mixure of Experts (MoE) made with two microsoft/phi-2 models, inspired by the mistralai/Mixtral-8x7B-v0.1 architecture. It performs better than each individual expert.

You can try it out using this Space.

🏆 Evaluation

The evaluation was performed using LLM AutoEval on Nous suite.

ModelAGIEvalGPT4AllTruthfulQABigbenchAverage
phixtral-2x2_834.170.4448.7837.8247.78
dolphin-2_6-phi-233.1269.8547.3937.246.89
phi-2-dpo30.3971.6850.7534.946.93
phi-227.9870.844.4335.2144.61

Check YALL - Yet Another LLM Leaderboard to compare it with other models.

🧩 Configuration

The model has been made with a custom version of the mergekit library (mixtral branch) and the following configuration:

base_model: cognitivecomputations/dolphin-2_6-phi-2
gate_mode: cheap_embed
experts:
  - source_model: cognitivecomputations/dolphin-2_6-phi-2
    positive_prompts: [""]
  - source_model: lxuechen/phi-2-dpo
    positive_prompts: [""]

💻 Usage

Here's a Colab notebook to run Phixtral in 4-bit precision on a free T4 GPU.

!pip install -q --upgrade transformers einops accelerate bitsandbytes

import torch
from transformers import AutoModelForCausalLM, AutoTokenizer

model_name = "phixtral-2x2_8"
instruction = '''
    def print_prime(n):
        """
        Print all primes between 1 and n
        """
'''

torch.set_default_device("cuda")

# Load the model and tokenizer
model = AutoModelForCausalLM.from_pretrained(
    f"mlabonne/{model_name}", 
    torch_dtype="auto", 
    load_in_4bit=True, 
    trust_remote_code=True
)
tokenizer = AutoTokenizer.from_pretrained(
    f"mlabonne/{model_name}", 
    trust_remote_code=True
)

# Tokenize the input string
inputs = tokenizer(
    instruction, 
    return_tensors="pt", 
    return_attention_mask=False
)

# Generate text using the model
outputs = model.generate(**inputs, max_length=200)

# Decode and print the output
text = tokenizer.batch_decode(outputs)[0]
print(text)

Inspired by mistralai/Mixtral-8x7B-v0.1, you can specify the num_experts_per_tok and num_local_experts in the config.json file (2 for both by default). This configuration is automatically loaded in configuration.py.

vince62s implemented the MoE inference code in the modeling_phi.py file. In particular, see the MoE class.

🤝 Acknowledgments

A special thanks to vince62s for the inference code and the dynamic configuration of the number of experts. He was very patient and helped me to debug everything.

Thanks to Charles Goddard for the mergekit library and the implementation of the MoE for clowns.

Thanks to ehartford and lxuechen for their fine-tuned phi-2 models.

Как запустить

На своей GPU в ailist. Цена — по текущим предложениям провайдеров

GPU в ailist

Универсальный рантайм

Нельзя запустить

Модели нужен код из репозитория; автор пока не в списке доверенных организаций.

Класс архитектуры
PhiForCausalLM
Ревизия весов
7744a97

0 моделей