Your first prediction

Load the model once, then call predict on any Khmer text.

Python
from neam import Neam

ner = Neam.from_pretrained("MoriartyPuth/neam")
result = ner.predict("លោក ហ៊ុន ម៉ាណែត បានជួបជាមួយក្រសួងសុខាភិបាលនៅរាជធានីភ្នំពេញ។")

for entity in result["entities"]:
    print(entity["label"], entity["text"], entity["start"], entity["end"])
Output
PER លោក ហ៊ុន ម៉ាណែត 0 15
ORG ក្រសួងសុខាភិបាល 27 42
LOC រាជធានីភ្នំពេញ 44 58

The sentence means "Mr. Hun Manet met with the Ministry of Health in Phnom Penh." Neam found the person, the ministry and the city, and start and end point at the exact characters, so text[27:42] is ក្រសួងសុខាភិបាល.

Load once, predict many times

Loading reads seven models into memory, which takes a few seconds (3.7 s on a laptop from the local cache). After that, each call is fast: about 2 seconds for a 1,600-character article on a laptop CPU, and much less for a sentence. Keep one Neam object and reuse it.

Python
ner = Neam.from_pretrained("MoriartyPuth/neam")

for text in texts:
    names = ner.predict(text)["entities"]

Loading options

ArgumentDefaultWhat it does
model"MoriartyPuth/neam"A Hugging Face model ID or a local folder.
deviceCUDA if available, else CPUFor example "cpu" or "cuda".
revisionlatestA Hub tag or commit, for example "v0.2.0", to pin the exact weights.
max_lengthfrom the model (128)Subwords per window. Leave it unless you know why.

Neam.from_pretrained(...) and Neam(...) do the same thing.

Python
ner = Neam.from_pretrained("MoriartyPuth/neam", revision="v0.2.0", device="cpu")
Use the package, not a plain pipeline. The model on the Hub is an ensemble of seven checkpoints with its own decoding and display rules. Loading one member with the standard transformers pipeline gives noticeably worse results.