Run this model with HF Jobs
Run togethercomputer/m2-bert-80M-2k 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. 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 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 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use togethercomputer/m2-bert-80M-2k with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("fill-mask", model="togethercomputer/m2-bert-80M-2k", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoModelForMaskedLM model = AutoModelForMaskedLM.from_pretrained("togethercomputer/m2-bert-80M-2k", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
Update README.md
Browse files1 unmodified line2345678910111213145 unmodified lines20212223242526272 unmodified lines3031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394958 unmodified lines1041051061071 unmodified linelicense: apache-2.0language:- enpipeline_tag: text-classificationinference: false---# Monarch Mixer-BERTAn 80M checkpoint of M2-BERT, pretrained with sequence length 2048, and it has been fine-tuned for long-context retrieval.Check out the paper [Monarch Mixer: A Simple Sub-Quadratic GEMM-Based Architecture](https://arxiv.org/abs/2310.12109) and our [blog post]() on retrieval for more on how we trained this model for long sequence.5 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)2 unmodified linesYou 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])```## AcknowledgmentsAlycia Lee helped with AutoModel support.8 unmodified linesbooktitle={Advances in Neural Information Processing Systems},year={2023}}```1 unmodified line234567891011121314155 unmodified lines21222324252627282 unmodified lines3132333435368 unmodified lines454647481 unmodified linelicense: apache-2.0language:- enpipeline_tag: fill-maskinference: false---# Monarch Mixer-BERTAn 80M checkpoint of M2-BERT, pretrained with sequence length 2048.**This is a BERT-style model that has not been fine-tuned. We recommend fine-tuning it for specific use cases before using it.**Check out the paper [Monarch Mixer: A Simple Sub-Quadratic GEMM-Based Architecture](https://arxiv.org/abs/2310.12109) and our [blog post]() on retrieval for more on how we trained this model for long sequence.5 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)2 unmodified linesYou 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).## AcknowledgmentsAlycia Lee helped with AutoModel support.8 unmodified linesbooktitle={Advances in Neural Information Processing Systems},year={2023}}```
README.md+6-65