MCPcopy Create free account
hub / github.com/OpenNMT/CTranslate2 / register_scoring_result

Function register_scoring_result

python/cpp/scoring_result.cc:10–26  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8 namespace python {
9
10 void register_scoring_result(py::module& m) {
11 py::class_<ScoringResult>(m, "ScoringResult", "A scoring result.")
12
13 .def_readonly("tokens", &ScoringResult::tokens,
14 "The scored tokens.")
15 .def_readonly("log_probs", &ScoringResult::tokens_score,
16 "Log probability of each token")
17
18 .def("__repr__", [](const ScoringResult& result) {
19 return "ScoringResult(tokens=" + std::string(py::repr(py::cast(result.tokens)))
20 + ", log_probs=" + std::string(py::repr(py::cast(result.tokens_score)))
21 + ")";
22 })
23 ;
24
25 declare_async_wrapper<ScoringResult>(m, "AsyncScoringResult");
26 }
27
28 }
29}

Callers 1

PYBIND11_MODULEFunction · 0.85

Calls 1

stringFunction · 0.85

Tested by

no test coverage detected