Comments (1)
hey @thu-yn thanks for your question!
if you train your model with our library, your resulting model should support generate
function as:
instruction = "Which dog breed do people think is cuter, poodle or doodle?"
# tokenize and prepare the input
prompt = prompt_no_input_template % instruction
prompt = tokenizer(prompt, return_tensors="pt").to(device)
base_unit_location = prompt["input_ids"].shape[-1] - 1 # last position
_, reft_response = reft_model.generate(
prompt, unit_locations={"sources->base": (None, [[[base_unit_location]]])},
intervene_on_prompt=True, max_new_tokens=512, do_sample=True,
eos_token_id=tokenizer.eos_token_id, early_stopping=True
)
print(tokenizer.decode(reft_response[0], skip_special_tokens=True))
all of our evaluation scripts rely on huggingface's generate API --- so it should just work out of the box! let me know if you find any issue with that! thanks! note that the generate takes a couple more arguments, e.g., the intervening token positions. internally, we call huggingface generate
call (which is done in our pyvene
library https://github.com/stanfordnlp/pyvene/blob/main/pyvene/models/intervenable_base.py#L1585)
from pyreft.
Related Issues (20)
- Getting issue while loading Phi3 in reft_model HOT 9
- [P1] How did you create the validation set for Commonsense reasoning hyperparameter tuning? HOT 5
- [P0] Additional intervention arguments are not saved correctly, e.g. `add_bias`
- [P1] Getting error as IntervenableModel.train() takes 1 positional argument but 2 were given HOT 4
- [P0] Make `make_last_position_supervised_data_module` parallelizable to speed up processing! HOT 2
- [P1] Loading REFT fro RoBERTa Models HOT 3
- [P1] TypeError: train() takes 1 positional argument but 2 were given HOT 1
- [P1] Loreft example gsm8k train gives: RuntimeError: output with shape [64, 1, 7] doesn't match the broadcast shape [64, 0, 7] HOT 3
- forward() got an unexpected keyword argument 'unit_locations' HOT 2
- [P1] Model Compatibility HOT 2
- [P1] Transitioning from peft to pyreft for Classification Approach HOT 1
- [P1] Questions on differences between paper and code HOT 2
- [P1] Multiple Positions Intervention HOT 1
- [P0] Does this project support turning in 4bit or 8bit Quantify? HOT 5
- [P1] Loss decrease slow in readme demo when use NousResearch/Llama-2-7b-chat-hf HOT 2
- [P1] Is it possible to merge the base model + REFT model into only model? HOT 1
- transformers_modules.microsoft.Phi-3-mini-4k-instruct.d269012bea6fbe38ce7752c8940fea010eea3383.modeling_phi3.Phi3ForCausalLM HOT 1
- [P1] [Error] can not use bfloat16 and TypeError: Object of type type is not JSON serializable HOT 12
- [Major][pyreft-core] ReFT next release items
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pyreft.