BatsResearch / bonito

A lightweight library for generating synthetic instruction tuning datasets for your data without GPT.
BSD 3-Clause "New" or "Revised" License
702 stars 46 forks source link

ImportError: cannot import name 'SamplingParams' from 'bonito' (/content/bonito/bonito/__init__.py) #23

Closed KaifAhmad1 closed 6 months ago

KaifAhmad1 commented 6 months ago
from bonito import Bonito, SamplingParams
from datasets import load_dataset

# @title AutoBonito🐟

# @markdown ### Paramaters
bonito_model = "NousResearch/Genstruct-7B"  # @param {type:"string"}
dataset = "kaifahmad/indian-history-hindi-QA-3.4k" # @param {type:"string"}
unannotated_text = "unannotated_alhzheimer_corpus.txt" # @param {type:"string"}
split = "train" # @param {type:"string"}
number_of_samples = "100" # @param {type:"string"}
max_tokens = 256 # @param {type:"string"}

n = 1 # @param {type:"string"}
top_p = 0.95 # @param {type:"string"}
temperature = 0.5 # @param {type:"string"}

context_column = "Question"  # @param {type:"string"}
task_type = "qa"  # @param {type:"string"}

# Initialize the Bonito model
bonito = Bonito(bonito_model)

# load dataset with unannotated text
unannotated_text = load_dataset(
    dataset,
    unannotated_text
)[split].select(range(number_of_samples))

# Generate synthetic instruction tuning dataset
sampling_params = SamplingParams(max_tokens=256, top_p=0.95, temperature=0.5, n=1)
synthetic_dataset = bonito.generate_tasks(
    unannotated_text,
    context_col=context_column,
    task_type=task_type,
    sampling_params=sampling_params
)
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
[<ipython-input-2-c5929ed415ec>](https://localhost:8080/#) in <cell line: 1>()
----> 1 from bonito import Bonito, SamplingParams
      2 from datasets import load_dataset
      3 
      4 # @title AutoBonito🐟
      5 

ImportError: cannot import name 'SamplingParams' from 'bonito' (/content/bonito/bonito/__init__.py)

---------------------------------------------------------------------------
NOTE: If your import is failing due to a missing package, you can
manually install dependencies using either !pip or !apt.

To view examples of installing some common dependencies, click the
"Open Examples" button below.
---------------------------------------------------------------------------
nihalnayak commented 6 months ago

We are importing SamplingParams from the vllm package. You can refer to the README.md in the Bonito package.

You can fix your issue by fixing the imports:

from bonito import Bonito
from vllm import SamplingParams

You are also using the bonito_model = NousResearch/Genstruct-7B. You might not get the right output. We recommend using BatsResearch/bonito-v1.