Instructions to use M-CLIP/Swedish-500k with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use M-CLIP/Swedish-500k with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("feature-extraction", model="M-CLIP/Swedish-500k")# Load model directly from transformers import AutoTokenizer, AutoModel tokenizer = AutoTokenizer.from_pretrained("M-CLIP/Swedish-500k") model = AutoModel.from_pretrained("M-CLIP/Swedish-500k") - Notebooks
- Google Colab
- Kaggle
# Load model directly
from transformers import AutoTokenizer, AutoModel
tokenizer = AutoTokenizer.from_pretrained("M-CLIP/Swedish-500k")
model = AutoModel.from_pretrained("M-CLIP/Swedish-500k")Quick Links
Swe-CLIP 500k
Usage
To use this model along with the original CLIP vision encoder you need to download the code and additional linear weights from the Multilingual-CLIP Github. Once this is done, you can load and use the model with the following code
from src import multilingual_clip
model = multilingual_clip.load_model('Swe-CLIP-500k')
embeddings = model(['Älgen är skogens konung!', 'Alla isbjörnar är vänsterhänta'])
print(embeddings.shape)
# Yields: torch.Size([2, 640])
About
A KB/Bert-Swedish-Cased tuned to match the embedding space of the CLIP text encoder which accompanies the Res50x4 vision encoder.
Training data pairs was generated by sampling 500k sentences from the combined descriptions of GCC + MSCOCO + VizWiz, and translating them into Swedish. All translation was done using the Huggingface Opus Model, which seemingly procudes higher quality translations than relying on the AWS translate service.
- Downloads last month
- 10
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("feature-extraction", model="M-CLIP/Swedish-500k")