Image-Text-to-Text
Transformers
Safetensors
English
internvl_chat
feature-extraction
mathematics
reasoning
multi-modal-qa
math-qa
figure-qa
geometry-qa
math-word-problem
textbook-qa
vqa
geometry-diagram
synthetic-scene
chart
plot
scientific-figure
table
function-plot
abstract-scene
puzzle-test
document-image
science
conversational
custom_code
Run this model with HF Jobs
Run MathLLMs/MathCoder-VL-2B on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs and TRL to fine-tune https://huggingface.co/MathLLMs/MathCoder-VL-2B. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/MathLLMs/MathCoder-VL-2B on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Evaluate on a benchmark
Use HF Jobs to evaluate https://huggingface.co/MathLLMs/MathCoder-VL-2B. Ask me which benchmark to run, then save the scores and the per-example results to a new dataset repo. Run `hf jobs --help` first to learn the CLI.
Quantize for lower memory use
Use HF Jobs to create a 4-bit version of https://huggingface.co/MathLLMs/MathCoder-VL-2B. Push it to a new model repo, then reload it from there and report its memory footprint. Run `hf jobs --help` first to learn the CLI.
Instructions to use MathLLMs/MathCoder-VL-2B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use MathLLMs/MathCoder-VL-2B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="MathLLMs/MathCoder-VL-2B", trust_remote_code=True) messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] pipe(text=messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("MathLLMs/MathCoder-VL-2B", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use MathLLMs/MathCoder-VL-2B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "MathLLMs/MathCoder-VL-2B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "MathLLMs/MathCoder-VL-2B", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker
docker model run hf.co/MathLLMs/MathCoder-VL-2B
- SGLang
How to use MathLLMs/MathCoder-VL-2B with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "MathLLMs/MathCoder-VL-2B" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "MathLLMs/MathCoder-VL-2B", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "MathLLMs/MathCoder-VL-2B" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "MathLLMs/MathCoder-VL-2B", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }' - Docker Model Runner
How to use MathLLMs/MathCoder-VL-2B with Docker Model Runner:
docker model run hf.co/MathLLMs/MathCoder-VL-2B
Add files using upload-large-folder tool
Browse filesFiles changed (14)
- .gitattributes+4
- README.md+70-3
- added_tokens.jsonAdded+15
- config.jsonAdded+204
- examples/fig1.pngAdded
- examples/fig2.pngAdded
- examples/fig4.pngAdded
- examples/tab1.pngAdded
- generation_config.jsonAdded+4
- model.safetensorsAdded+3
- special_tokens_map.jsonAdded+75
- tokenization_internlm2.pyAdded+235
- tokenizer.modelAdded+3
- tokenizer_config.jsonAdded+215
32 unmodified lines33343532 unmodified lines*.zip filter=lfs diff=lfs merge=lfs -text*.zst filter=lfs diff=lfs merge=lfs -text*tfevents* filter=lfs diff=lfs merge=lfs -text32 unmodified lines3334353637383932 unmodified lines*.zip filter=lfs diff=lfs merge=lfs -text*.zst filter=lfs diff=lfs merge=lfs -text*tfevents* filter=lfs diff=lfs merge=lfs -textexamples/fig4.png filter=lfs diff=lfs merge=lfs -textexamples/fig2.png filter=lfs diff=lfs merge=lfs -textexamples/tab1.png filter=lfs diff=lfs merge=lfs -textexamples/fig1.png filter=lfs diff=lfs merge=lfs -text
123---license: apache-2.0---12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970---license: apache-2.0language:- enmetrics:- accuracypipeline_tag: text-generation---# MathCoder: Seamless Code Integration in LLMs for Enhanced Mathematical ReasoningPaper: [https://arxiv.org/pdf/2310.03731.pdf](https://arxiv.org/pdf/2310.03731.pdf)Repo: [https://github.com/mathllm/MathCoder](https://github.com/mathllm/MathCoder)## IntroductionWe introduce MathCoder, a series of open-source large language models (LLMs) specifically tailored for general math problem-solving.| Base Model: Llama-2 | Base Model: Code Llama ||-------------------------------------------------------------------|-----------------------------------------------------------------------|| [MathCoder-L-7B](https://huggingface.co/MathLLM/MathCoder-L-7B) | [MathCoder-CL-7B](https://huggingface.co/MathLLM/MathCoder-CL-7B) || [MathCoder-L-13B](https://huggingface.co/MathLLM/MathCoder-L-13B) | [MathCoder-CL-34B](https://huggingface.co/MathLLM/MathCoder-CL-34B) |## Training DataThe models are trained on the [MathCodeInstruct](https://huggingface.co/datasets/MathLLM/MathCodeInstruct) Dataset.## Training ProcedureThe models are fine-tuned with the MathCodeInstruct dataset using the original Llama-2 and CodeLlama models as base models. Check out our paper and repo for more details.## Evaluation<br><div align="center"><img src="result.png" width="100%" title="Result Figure"></div>## UsageYou can use the models through Huggingface's Transformers library. Use the pipeline function to create a text-generation pipeline with the model of your choice, then feed in a math problem to get the solution.Check our Github repo for datails.## **Citation**Please cite the paper if you use our data, model or code. Please also kindly cite the original dataset papers.```@inproceedings{wang2024mathcoder,title={MathCoder: Seamless Code Integration in {LLM}s for Enhanced Mathematical Reasoning},author={Ke Wang and Houxing Ren and Aojun Zhou and Zimu Lu and Sichun Luo and Weikang Shi and Renrui Zhang and Linqi Song and Mingjie Zhan and Hongsheng Li},booktitle={The Twelfth International Conference on Learning Representations},year={2024},url={https://openreview.net/forum?id=z8TW0ttBPp}}``````@inproceedings{zhou2024solving,title={Solving Challenging Math Word Problems Using {GPT}-4 Code Interpreter with Code-based Self-Verification},author={Aojun Zhou and Ke Wang and Zimu Lu and Weikang Shi and Sichun Luo and Zipeng Qin and Shaoqing Lu and Anya Jia and Linqi Song and Mingjie Zhan and Hongsheng Li},booktitle={The Twelfth International Conference on Learning Representations},year={2024},url={https://openreview.net/forum?id=c8McWs4Av0}}```
123456789101112131415{ "</box>": 92552, "</img>": 92545, "</quad>": 92548, "</ref>": 92550, "<IMG_CONTEXT>": 92546, "<box>": 92551, "<img>": 92544, "<quad>": 92547, "<ref>": 92549, "<|/execution|>": 92556, "<|/python|>": 92554, "<|execution|>": 92555, "<|python|>": 92553}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204{ "_commit_hash": null, "_name_or_path": "./pretrained/Mini-InternVL-Chat-2B-V1-5", "architectures": [ "InternVLChatModel" ], "auto_map": { "AutoConfig": "configuration_internvl_chat.InternVLChatConfig", "AutoModel": "modeling_internvl_chat.InternVLChatModel", "AutoModelForCausalLM": "modeling_internvl_chat.InternVLChatModel" }, "downsample_ratio": 0.5, "dynamic_image_size": true, "force_image_size": 448, "llm_config": { "_name_or_path": "pretrained/internlm2-chat-1_8b", "add_cross_attention": false, "architectures": [ "InternLM2ForCausalLM" ], "attn_implementation": "flash_attention_2", "auto_map": { "AutoConfig": "configuration_internlm2.InternLM2Config", "AutoModel": "modeling_internlm2.InternLM2ForCausalLM", "AutoModelForCausalLM": "modeling_internlm2.InternLM2ForCausalLM" }, "bad_words_ids": null, "begin_suppress_tokens": null, "bias": false, "bos_token_id": 1, "chunk_size_feed_forward": 0, "cross_attention_hidden_size": null, "decoder_start_token_id": null, "diversity_penalty": 0.0, "do_sample": false, "early_stopping": false, "encoder_no_repeat_ngram_size": 0, "eos_token_id": 2, "exponential_decay_length_penalty": null, "finetuning_task": null, "forced_bos_token_id": null, "forced_eos_token_id": null, "hidden_act": "silu", "hidden_size": 2048, "id2label": { "0": "LABEL_0", "1": "LABEL_1" }, "initializer_range": 0.02, "intermediate_size": 8192, "is_decoder": false, "is_encoder_decoder": false, "label2id": { "LABEL_0": 0, "LABEL_1": 1 }, "length_penalty": 1.0, "max_length": 20, "max_position_embeddings": 32768, "min_length": 0, "model_type": "internlm2", "no_repeat_ngram_size": 0, "num_attention_heads": 16, "num_beam_groups": 1, "num_beams": 1, "num_hidden_layers": 24, "num_key_value_heads": 8, "num_return_sequences": 1, "output_attentions": false, "output_hidden_states": false, "output_scores": false, "pad_token_id": 2, "prefix": null, "problem_type": null, "pruned_heads": {}, "remove_invalid_values": false, "repetition_penalty": 1.0, "return_dict": true, "return_dict_in_generate": false, "rms_norm_eps": 1e-05, "rope_scaling": { "factor": 3.0, "type": "dynamic" }, "rope_theta": 1000000, "sep_token_id": null, "suppress_tokens": null, "task_specific_params": null, "temperature": 1.0, "tf_legacy_loss": false, "tie_encoder_decoder": false, "tie_word_embeddings": false, "tokenizer_class": null, "top_k": 50, "top_p": 1.0, "torch_dtype": "bfloat16", "torchscript": false, "transformers_version": "4.39.0", "typical_p": 1.0, "use_bfloat16": false, "use_cache": false, "vocab_size": 92557 }, "max_dynamic_patch": 12, "min_dynamic_patch": 1, "model_type": "internvl_chat", "pad2square": false, "ps_version": "v2", "select_layer": -1, "template": "internlm2-chat", "torch_dtype": "bfloat16", "transformers_version": null, "use_backbone_lora": 0, "use_llm_lora": 0, "use_thumbnail": true, "vision_config": { "_name_or_path": "OpenGVLab/InternViT-300M-448px", "add_cross_attention": false, "architectures": [ "InternVisionModel" ], "attention_dropout": 0.0, "auto_map": { "AutoConfig": "configuration_intern_vit.InternVisionConfig", "AutoModel": "modeling_intern_vit.InternVisionModel" }, "bad_words_ids": null, "begin_suppress_tokens": null, "bos_token_id": null, "chunk_size_feed_forward": 0, "cross_attention_hidden_size": null, "decoder_start_token_id": null, "diversity_penalty": 0.0, "do_sample": false, "drop_path_rate": 0.1, "dropout": 0.0, "early_stopping": false, "encoder_no_repeat_ngram_size": 0, "eos_token_id": null, "exponential_decay_length_penalty": null, "finetuning_task": null, "forced_bos_token_id": null, "forced_eos_token_id": null, "hidden_act": "gelu", "hidden_size": 1024, "id2label": { "0": "LABEL_0", "1": "LABEL_1" }, "image_size": 448, "initializer_factor": 1.0, "initializer_range": 0.02, "intermediate_size": 4096, "is_decoder": false, "is_encoder_decoder": false, "label2id": { "LABEL_0": 0, "LABEL_1": 1 }, "layer_norm_eps": 1e-06, "length_penalty": 1.0, "max_length": 20, "min_length": 0, "model_type": "intern_vit_6b", "no_repeat_ngram_size": 0, "norm_type": "layer_norm", "num_attention_heads": 16, "num_beam_groups": 1, "num_beams": 1, "num_channels": 3, "num_hidden_layers": 24, "num_return_sequences": 1, "output_attentions": false, "output_hidden_states": false, "output_scores": false, "pad_token_id": null, "patch_size": 14, "prefix": null, "problem_type": null, "pruned_heads": {}, "qk_normalization": false, "qkv_bias": true, "remove_invalid_values": false, "repetition_penalty": 1.0, "return_dict": true, "return_dict_in_generate": false, "sep_token_id": null, "suppress_tokens": null, "task_specific_params": null, "temperature": 1.0, "tf_legacy_loss": false, "tie_encoder_decoder": false, "tie_word_embeddings": true, "tokenizer_class": null, "top_k": 50, "top_p": 1.0, "torch_dtype": "bfloat16", "torchscript": false, "transformers_version": "4.39.0", "typical_p": 1.0, "use_bfloat16": true, "use_flash_attn": true }}1234{ "_from_model_config": true, "transformers_version": "4.39.0"}123version https://git-lfs.github.com/spec/v1oid sha256:124905df22268e391e45bd5d2b97e476b154cd70f0f77a9d334d3fb98ee725f7size 4411603808123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475{ "additional_special_tokens": [ "<|im_start|>", "<|im_end|>", "<|action_start|>", "<|action_end|>", "<|interpreter|>", "<|plugin|>", "<img>", "</img>", "<IMG_CONTEXT>", "<quad>", "</quad>", "<ref>", "</ref>", "<box>", "</box>", { "content": "<|python|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false }, { "content": "<|/python|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false }, { "content": "<|execution|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false }, { "content": "<|/execution|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false } ], "bos_token": { "content": "<s>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false }, "eos_token": { "content": "</s>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false }, "pad_token": { "content": "</s>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false }, "unk_token": { "content": "<unk>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false }}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235# Copyright (c) The InternLM team and The HuggingFace Inc. team. All rights reserved.## This code is based on transformers/src/transformers/models/llama/tokenization_llama.py## Licensed under the Apache License, Version 2.0 (the "License");# you may not use this file except in compliance with the License.# You may obtain a copy of the License at## http://www.apache.org/licenses/LICENSE-2.0## Unless required by applicable law or agreed to in writing, software# distributed under the License is distributed on an "AS IS" BASIS,# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.# See the License for the specific language governing permissions and# limitations under the License.
"""Tokenization classes for InternLM."""import osfrom shutil import copyfilefrom typing import Any, Dict, List, Optional, Tuple
import sentencepiece as spmfrom transformers.tokenization_utils import PreTrainedTokenizerfrom transformers.utils import logging
logger = logging.get_logger(__name__)
VOCAB_FILES_NAMES = {'vocab_file': './tokenizer.model'}
PRETRAINED_VOCAB_FILES_MAP = {}
# Modified from transformers.model.llama.tokenization_llama.LlamaTokenizerclass InternLM2Tokenizer(PreTrainedTokenizer): """ Construct a InternLM2 tokenizer. Based on byte-level Byte-Pair-Encoding.
Args: vocab_file (`str`): Path to the vocabulary file. """
vocab_files_names = VOCAB_FILES_NAMES pretrained_vocab_files_map = PRETRAINED_VOCAB_FILES_MAP model_input_names = ['input_ids', 'attention_mask'] _auto_class = 'AutoTokenizer'
def __init__( self, vocab_file, unk_token='<unk>', bos_token='<s>', eos_token='</s>', pad_token='</s>', sp_model_kwargs: Optional[Dict[str, Any]] = None, add_bos_token=True, add_eos_token=False, decode_with_prefix_space=False, clean_up_tokenization_spaces=False, **kwargs, ): self.sp_model_kwargs = {} if sp_model_kwargs is None else sp_model_kwargs self.vocab_file = vocab_file self.add_bos_token = add_bos_token self.add_eos_token = add_eos_token self.decode_with_prefix_space = decode_with_prefix_space self.sp_model = spm.SentencePieceProcessor(**self.sp_model_kwargs) self.sp_model.Load(vocab_file) self._no_prefix_space_tokens = None super().__init__( bos_token=bos_token, eos_token=eos_token, unk_token=unk_token, pad_token=pad_token, clean_up_tokenization_spaces=clean_up_tokenization_spaces, **kwargs, )
@property def no_prefix_space_tokens(self): if self._no_prefix_space_tokens is None: vocab = self.convert_ids_to_tokens(list(range(self.vocab_size))) self._no_prefix_space_tokens = {i for i, tok in enumerate(vocab) if not tok.startswith('▁')} return self._no_prefix_space_tokens
@property def vocab_size(self): """Returns vocab size""" return self.sp_model.get_piece_size()
@property def bos_token_id(self) -> Optional[int]: return self.sp_model.bos_id()
@property def eos_token_id(self) -> Optional[int]: return self.sp_model.eos_id()
def get_vocab(self): """Returns vocab as a dict""" vocab = {self.convert_ids_to_tokens(i): i for i in range(self.vocab_size)} vocab.update(self.added_tokens_encoder) return vocab
def _tokenize(self, text): """Returns a tokenized string.""" return self.sp_model.encode(text, out_type=str)
def _convert_token_to_id(self, token): """Converts a token (str) in an id using the vocab.""" return self.sp_model.piece_to_id(token)
def _convert_id_to_token(self, index): """Converts an index (integer) in a token (str) using the vocab.""" token = self.sp_model.IdToPiece(index) return token
def _maybe_add_prefix_space(self, tokens, decoded): if tokens and tokens[0] not in self.no_prefix_space_tokens: return ' ' + decoded else: return decoded
def convert_tokens_to_string(self, tokens): """Converts a sequence of tokens (string) in a single string.""" current_sub_tokens = [] out_string = '' prev_is_special = False for token in tokens: # make sure that special tokens are not decoded using sentencepiece model if token in self.all_special_tokens: if not prev_is_special: out_string += ' ' out_string += self.sp_model.decode(current_sub_tokens) + token prev_is_special = True current_sub_tokens = [] else: current_sub_tokens.append(token) prev_is_special = False out_string += self.sp_model.decode(current_sub_tokens) out_string = self.clean_up_tokenization(out_string) out_string = self._maybe_add_prefix_space(tokens=tokens, decoded=out_string) return out_string[1:]
def save_vocabulary(self, save_directory, filename_prefix: Optional[str] = None) -> Tuple[str]: """ Save the vocabulary and special tokens file to a directory.
Args: save_directory (`str`): The directory in which to save the vocabulary.
Returns: `Tuple(str)`: Paths to the files saved. """ if not os.path.isdir(save_directory): logger.error(f'Vocabulary path ({save_directory}) should be a directory') return out_vocab_file = os.path.join( save_directory, (filename_prefix + '-' if filename_prefix else '') + VOCAB_FILES_NAMES['vocab_file'] )
if os.path.abspath(self.vocab_file) != os.path.abspath(out_vocab_file) and os.path.isfile(self.vocab_file): copyfile(self.vocab_file, out_vocab_file) elif not os.path.isfile(self.vocab_file): with open(out_vocab_file, 'wb') as fi: content_spiece_model = self.sp_model.serialized_model_proto() fi.write(content_spiece_model)
return (out_vocab_file,)
def build_inputs_with_special_tokens(self, token_ids_0, token_ids_1=None): if self.add_bos_token: bos_token_ids = [self.bos_token_id] else: bos_token_ids = []
output = bos_token_ids + token_ids_0
if token_ids_1 is not None: output = output + token_ids_1
if self.add_eos_token: output = output + [self.eos_token_id]
return output
def get_special_tokens_mask( self, token_ids_0: List[int], token_ids_1: Optional[List[int]] = None, already_has_special_tokens: bool = False ) -> List[int]: """ Retrieve sequence ids from a token list that has no special tokens added. This method is called when adding special tokens using the tokenizer `prepare_for_model` method.
Args: token_ids_0 (`List[int]`): List of IDs. token_ids_1 (`List[int]`, *optional*): Optional second list of IDs for sequence pairs. already_has_special_tokens (`bool`, *optional*, defaults to `False`): Whether or not the token list is already formatted with special tokens for the model.
Returns: `List[int]`: A list of integers in the range [0, 1]: 1 for a special token, 0 for a sequence token. """ if already_has_special_tokens: return super().get_special_tokens_mask( token_ids_0=token_ids_0, token_ids_1=token_ids_1, already_has_special_tokens=True )
if token_ids_1 is None: return [1] + ([0] * len(token_ids_0)) + [1] return [1] + ([0] * len(token_ids_0)) + [1, 1] + ([0] * len(token_ids_1)) + [1]
def create_token_type_ids_from_sequences( self, token_ids_0: List[int], token_ids_1: Optional[List[int]] = None ) -> List[int]: """ Create a mask from the two sequences passed to be used in a sequence-pair classification task. T5 does not make use of token type ids, therefore a list of zeros is returned.
Args: token_ids_0 (`List[int]`): List of IDs. token_ids_1 (`List[int]`, *optional*): Optional second list of IDs for sequence pairs.
Returns: `List[int]`: List of zeros. """ eos = [self.eos_token_id]
if token_ids_1 is None: return len(token_ids_0 + eos) * [0] return len(token_ids_0 + eos + token_ids_1 + eos) * [0]123version https://git-lfs.github.com/spec/v1oid sha256:f868398fc4e05ee1e8aeba95ddf18ddcc45b8bce55d5093bead5bbf80429b48bsize 1477754123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215{ "added_tokens_decoder": { "0": { "content": "<unk>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "1": { "content": "<s>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "2": { "content": "</s>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "92538": { "content": "<|plugin|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "92539": { "content": "<|interpreter|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "92540": { "content": "<|action_end|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "92541": { "content": "<|action_start|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "92542": { "content": "<|im_end|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "92543": { "content": "<|im_start|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "92544": { "content": "<img>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "92545": { "content": "</img>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "92546": { "content": "<IMG_CONTEXT>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "92547": { "content": "<quad>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "92548": { "content": "</quad>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "92549": { "content": "<ref>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "92550": { "content": "</ref>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "92551": { "content": "<box>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "92552": { "content": "</box>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "92553": { "content": "<|python|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "92554": { "content": "<|/python|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "92555": { "content": "<|execution|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "92556": { "content": "<|/execution|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true } }, "additional_special_tokens": [ "<|im_start|>", "<|im_end|>", "<|action_start|>", "<|action_end|>", "<|interpreter|>", "<|plugin|>", "<img>", "</img>", "<IMG_CONTEXT>", "<quad>", "</quad>", "<ref>", "</ref>", "<box>", "</box>", "<|python|>", "<|/python|>", "<|execution|>", "<|/execution|>" ], "auto_map": { "AutoTokenizer": [ "tokenization_internlm2.InternLM2Tokenizer", null ] }, "bos_token": "<s>", "chat_template": "{{ bos_token }}{% for message in messages %}{{'<|im_start|>' + message['role'] + '\n' + message['content'] + '<|im_end|>' + '\n'}}{% endfor %}{% if add_generation_prompt %}{{ '<|im_start|>assistant\n' }}{% endif %}", "clean_up_tokenization_spaces": false, "eos_token": "</s>", "model_max_length": 4096, "pad_token": "</s>", "tokenizer_class": "InternLM2Tokenizer", "unk_token": "<unk>"}.gitattributes+4
README.md+70-3
added_tokens.jsonAdded+15
config.jsonAdded+204
examples/fig1.pngAdded

Large File Pointer Details
- SHA256: 6ee1a1c32320247e78277b68aaa73402755cb1969a9d03a3fba537ec1d2c2c2b
- Pointer size: 131 Bytes
- Size of remote file: 457 kB
examples/fig2.pngAdded

Large File Pointer Details
- SHA256: 14a97cb31580cf751975d9cd96b93bcf0d98496054b45ac0947105cb406678ed
- Pointer size: 131 Bytes
- Size of remote file: 377 kB
examples/fig4.pngAdded

Large File Pointer Details
- SHA256: eece3c82d77427f7d6cf3233da316d1d96bffe92d9faa3e46db1d84e28ba965f
- Pointer size: 131 Bytes
- Size of remote file: 121 kB
examples/tab1.pngAdded

Large File Pointer Details
- SHA256: c17882ef9f6ecf3b4cf33b4a89d8e2404341817c204340dd165a72b64d05730c
- Pointer size: 131 Bytes
- Size of remote file: 532 kB
generation_config.jsonAdded+4
model.safetensorsAdded+3
special_tokens_map.jsonAdded+75
tokenization_internlm2.pyAdded+235
tokenizer.modelAdded+3
tokenizer_config.jsonAdded+215