Run this model with HF Jobs
Run togethercomputer/m2-bert-80M-2k-retrieval 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 to fine-tune https://huggingface.co/togethercomputer/m2-bert-80M-2k-retrieval. 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/togethercomputer/m2-bert-80M-2k-retrieval 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.
Instructions to use togethercomputer/m2-bert-80M-2k-retrieval with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use togethercomputer/m2-bert-80M-2k-retrieval with Transformers:
# pip install -U transformers accelerate # Load model directly from transformers import AutoModelForSequenceClassification model = AutoModelForSequenceClassification.from_pretrained("togethercomputer/m2-bert-80M-2k-retrieval", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
Update README.md
Browse files1 unmodified line23456782 unmodified lines1112131415162 unmodified lines1920212223242526272829303132333435363738391 unmodified linelicense: apache-2.0language:- enpipeline_tag: sentence-similarityinference: false---2 unmodified linesThe 80M checkpoint for M2-BERT-base from the paper [Monarch Mixer: A Simple Sub-Quadratic GEMM-Based Architecture](https://arxiv.org/abs/2310.12109).This model has been pretrained with sequence length 2048, and it has been fine-tuned for long-context retrieval.This model was trained by Jon Saad-Falcon, Dan Fu, and Simran Arora.Check out our [GitHub](https://github.com/HazyResearch/m2/tree/main) for instructions on how to download and fine-tune it!2 unmodified linesYou can load this model using Hugging Face `AutoModel`:```pythonfrom transformers import AutoModelForMaskedLMmodel = AutoModelForMaskedLM.from_pretrained("togethercomputer/m2-bert-80M-2k-retrieval", trust_remote_code=True)```This model generates embeddings for retrieval. The embeddings have a dimensionality of 768:```from transformers import AutoTokenizer, AutoModelForMaskedLMmax_seq_length = 2048testing_string = "Every morning, I make a cup of coffee to start my day."model = AutoModelForMaskedLM.from_pretrained("togethercomputer/m2-bert-80M-2k-retrieval", trust_remote_code=True)tokenizer = AutoTokenizer.from_pretrained("bert-base-uncased", model_max_length=max_seq_length)input_ids = tokenizer([testing_string], return_tensors="pt", padding="max_length", return_token_type_ids=False, truncation=True, max_length=max_seq_length)outputs = model(**input_ids)embeddings = outputs['sentence_embedding']```1 unmodified line23456782 unmodified lines11121314151617182 unmodified lines2122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091921 unmodified linelicense: apache-2.0language:- enpipeline_tag: text-classificationinference: false---2 unmodified linesThe 80M checkpoint for M2-BERT-base from the paper [Monarch Mixer: A Simple Sub-Quadratic GEMM-Based Architecture](https://arxiv.org/abs/2310.12109).This model has been pretrained with sequence length 2048, and it has been fine-tuned for long-context retrieval.Check out our [blog post]() for more on how we trained this model for long sequence.This model was trained by Jon Saad-Falcon, Dan Fu, and Simran Arora.Check out our [GitHub](https://github.com/HazyResearch/m2/tree/main) for instructions on how to download and fine-tune it!2 unmodified linesYou can load this model using Hugging Face `AutoModel`:```pythonfrom transformers import AutoModelForSequenceClassificationmodel = AutoModelForSequenceClassification.from_pretrained("togethercomputer/m2-bert-80M-2k-retrieval",trust_remote_code=True)```You should expect to see a large error message about unused parameters for FlashFFTConv.If you'd like to load the model with FlashFFTConv, you can check out our [GitHub](https://github.com/HazyResearch/m2/tree/main).This model generates embeddings for retrieval. The embeddings have a dimensionality of 768:```pythonfrom transformers import AutoTokenizer, AutoModelForSequenceClassificationmax_seq_length = 2048testing_string = "Every morning, I make a cup of coffee to start my day."model = AutoModelForSequenceClassification.from_pretrained("togethercomputer/m2-bert-80M-2k-retrieval",trust_remote_code=True)tokenizer = AutoTokenizer.from_pretrained("bert-base-uncased",model_max_length=max_seq_length)input_ids = tokenizer([testing_string],return_tensors="pt",padding="max_length",return_token_type_ids=False,truncation=True,max_length=max_seq_length)outputs = model(**input_ids)embeddings = outputs['sentence_embedding']```You can also get embeddings from this model using the Together API as follows (you can find your API key [here](https://api.together.xyz/settings/api-keys)):```pythonimport osimport requestsdef generate_together_embeddings(text: str, model_api_string: str, api_key: str):url = "https://api.together.xyz/api/v1/embeddings"headers = {"accept": "application/json","content-type": "application/json","Authorization": f"Bearer {api_key}"}session = requests.Session()response = session.post(url,headers=headers,json={"input": text,"model": model_api_string})if response.status_code != 200:raise ValueError(f"Request failed with status code {response.status_code}: {response.text}")return response.json()['data'][0]['embedding']print(generate_together_embeddings('Hello world','togethercomputer/m2-bert-80M-2k-retrieval',os.environ['TOGETHER_API_KEY'])[:10])```
README.md+61-8