Views
No views yet
tok2vec listener)huggingface_hub.snapshot_download, the model files will be automatically fetched and cached locally. ```python
import spacy
from huggingface_hub import snapshot_download
# Load the pipeline
model_dir = snapshot_download(repo_id="JesseHuang922/lv_xlmr_large_1pct", repo_type="model")
nlp = spacy.load(model_dir)
```| Package | Minimum Version | Notes |
|---|---|---|
| spaCy | 3.8.7 | Main NLP framework |
| spacy-transformers | 1.3.9 | Integrates spaCy with Hugging Face Transformers |
| transformers | 4.49.0 | Hugging Face Transformers library |
| torch | 2.8.0 | PyTorch backend for transformers |
| tokenizers | 0.21.4 | Fast tokenizer support |
| safetensors | 0.6.2 | Secure tensor storage for transformer weights |
| huggingface-hub | 0.34.4 | Download and manage the model files from the Hugging Face Hub |
| Package | Minimum Version | Notes |
|---|---|---|
| hf-xet | 1.1.10 | if you need to download or upload large files from the Hugging Face Hub and use the Xet storage backend |
1pip install \
2spacy>=3.8.7 \
3spacy-transformers>=1.3.9 \
4transformers>=4.49.0 \
5torch>=2.8.0 \
6tokenizers>=0.21.4 \
7safetensors>=0.6.2 \
8huggingface-hub>=0.34.4 \
9hf-xet>=1.1.101import spacy
2import numpy as np
3from huggingface_hub import snapshot_download
4
5# Load the pipeline
6model_dir = snapshot_download(repo_id="JesseHuang922/lv_xlmr_large_1pct", repo_type="model")
7nlp = spacy.load(model_dir)
8
9# Example text
10text = """Baltijas jūras nosaukums ir devis nosaukumu baltu valodām un Baltijas valstīm.
11Terminu "Baltijas jūra" (Mare Balticum) pirmoreiz lietoja vācu hronists Brēmenes Ādams 11. gadsimtā."""
12
13# Process text
14doc = nlp(text)
15
16# ------------------------
17# Tokenization
18# ------------------------
19print("Tokens:")
20print([token.text for token in doc])
21
22# ------------------------
23# Lemmatization
24# ------------------------
25print("Lemmas:")
26print([token.lemma_ for token in doc])
27
28# ------------------------
29# Part-of-Speech Tagging
30# ------------------------
31print("POS tags:")
32for token in doc:
33 print(f"{token.text}: {token.pos_} ({token.tag_})")
34
35# ------------------------
36# Morphological Features
37# ------------------------
38print("Morphological features:")
39for token in doc:
40 print(f"{token.text}: {token.morph}")
41
42# ------------------------
43# Dependency Parsing
44# ------------------------
45print("Dependency parsing:")
46for token in doc:
47 print(f"{token.text} <--{token.dep_}-- {token.head.text}")
48
49# ------------------------
50# Sentence Segmentation
51# ------------------------
52print("Sentences:")
53for sent in doc.sents:
54 print(sent.text)
55
56# ------------------------
57# Check Pipeline Components
58# ------------------------
59print("Pipeline components:")
60print(nlp.pipe_names)
61
62# Transformer vectors
63vectors = np.vstack([token.vector for token in doc])
64print("Token vectors shape:", vectors.shape)