Instructions to use UmerKhan261/Fine-Tuned_BERT_German_Text_Classification with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use UmerKhan261/Fine-Tuned_BERT_German_Text_Classification with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="UmerKhan261/Fine-Tuned_BERT_German_Text_Classification")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForSequenceClassification tokenizer = AutoTokenizer.from_pretrained("UmerKhan261/Fine-Tuned_BERT_German_Text_Classification") model = AutoModelForSequenceClassification.from_pretrained("UmerKhan261/Fine-Tuned_BERT_German_Text_Classification", device_map="auto") - Notebooks
- Google Colab
- Kaggle
|
Download README.md from UmerKhan261/Fine-Tuned_BERT_German_Text_Classification: direct link, hf CLI and curl.
- Browser
- Download file 2.43 kB
-
https://huggingface.co/UmerKhan261/Fine-Tuned_BERT_German_Text_Classification/resolve/main/README.md
- Command line
-
hf download hf://UmerKhan261/Fine-Tuned_BERT_German_Text_Classification/README.md
-
curl -L -o README.md https://huggingface.co/UmerKhan261/Fine-Tuned_BERT_German_Text_Classification/resolve/main/README.md
2.43 kB
| license: mit | |
| Imagine you have a BERT model – the superhero of natural language understanding – but this one speaks German! We took the powerful "bert-base-german-cased" model and gave it a special mission: classify German text. After intense training, it's ready to help you tackle tasks like sentiment analysis, content categorization, or even semantic search in the German language. | |
| It is trained on 160K article summaries performs well on semantic search and text classification. I plan on to further fine tune this model with a much larger dataset approximately going to 511K article summaries. | |
| How to Use It: | |
| Let's see how you can unleash this German-speaking superhero on your data: | |
| Install Hugging Face Transformers: | |
| First, make sure you have the Hugging Face Transformers library installed. You can do this with pip: | |
| bash | |
| Copy code | |
| pip install transformers | |
| Load the Fine-Tuned Model: | |
| To use this fine-tuned BERT model, load it with the Transformers library: | |
| python | |
| Copy code | |
| from transformers import TFBertForSequenceClassification, BertTokenizer | |
| # Load the model and tokenizer | |
| model = TFBertForSequenceClassification.from_pretrained("path/to/your/model/directory") | |
| tokenizer = BertTokenizer.from_pretrained("bert-base-german-cased") | |
| Prepare Your Text: | |
| You can perform text classification with this model. Tokenize your text using the tokenizer: | |
| # Enter Text Input | |
| text = "Deine Textnachricht hier" # Your German text | |
| Get Predictions: | |
| Predict the label or class for your text: | |
| inputs = tokenizer(text, padding='max_length', truncation=True, max_length=128, return_tensors='tf', return_attention_mask=True) | |
| # Make a prediction | |
| with tf.device('/GPU:0'): # Specify the GPU device | |
| outputs = model(inputs) | |
| The predicted_class will give you the predicted label for your text. | |
| Semantic Search: | |
| For semantic search, you can create embeddings for a list of text and calculate the similarity between your query text and the documents, as discussed earlier. The model can help you find similar content with ease. | |
| That's it! Your fine-tuned BERT model is now your ally for handling various text-based tasks in the German language. Whether it's text classification or semantic search, this model is ready to assist you on your NLP adventures. | |
| Feel free to reach out if you have questions or need assistance in using this model to accomplish your German language processing tasks. Viel Erfolg! (Good luck!) |