(self,
path: str,
hf_cache_dir: Optional[str] = None,
max_seq_len: int = 2048,
tokenizer_path: Optional[str] = None,
tokenizer_kwargs: dict = dict(),
peft_path: Optional[str] = None,
tokenizer_only: bool = False,
model_kwargs: dict = dict(device_map='auto'),
generation_kwargs: dict = dict(),
meta_template: Optional[Dict] = None,
extract_pred_after_decode: bool = False,
batch_padding: bool = False,
pad_token_id: Optional[int] = None,
mode: str = 'none',
num_extra_tokens: int = 50)
| 696 | """ |
| 697 | |
| 698 | def __init__(self, |
| 699 | path: str, |
| 700 | hf_cache_dir: Optional[str] = None, |
| 701 | max_seq_len: int = 2048, |
| 702 | tokenizer_path: Optional[str] = None, |
| 703 | tokenizer_kwargs: dict = dict(), |
| 704 | peft_path: Optional[str] = None, |
| 705 | tokenizer_only: bool = False, |
| 706 | model_kwargs: dict = dict(device_map='auto'), |
| 707 | generation_kwargs: dict = dict(), |
| 708 | meta_template: Optional[Dict] = None, |
| 709 | extract_pred_after_decode: bool = False, |
| 710 | batch_padding: bool = False, |
| 711 | pad_token_id: Optional[int] = None, |
| 712 | mode: str = 'none', |
| 713 | num_extra_tokens: int = 50): |
| 714 | super().__init__(path=path, |
| 715 | hf_cache_dir=hf_cache_dir, |
| 716 | max_seq_len=max_seq_len, |
| 717 | tokenizer_path=tokenizer_path, |
| 718 | tokenizer_kwargs=tokenizer_kwargs, |
| 719 | peft_path=peft_path, |
| 720 | tokenizer_only=tokenizer_only, |
| 721 | generation_kwargs=generation_kwargs, |
| 722 | model_kwargs=model_kwargs, |
| 723 | meta_template=meta_template, |
| 724 | extract_pred_after_decode=extract_pred_after_decode, |
| 725 | batch_padding=batch_padding, |
| 726 | pad_token_id=pad_token_id, |
| 727 | mode=mode) |
| 728 | self.template_parser = APITemplateParser(meta_template) |
| 729 | # used to compensate for #tokens occupied by sth like system prompt |
| 730 | self.num_extra_tokens = num_extra_tokens |
| 731 | |
| 732 | def generate(self, |
| 733 | inputs: List[PromptType], |
nothing calls this directly
no test coverage detected