forked from OpenNMT/CTranslate2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscoring_result.cc
More file actions
29 lines (21 loc) · 822 Bytes
/
scoring_result.cc
File metadata and controls
29 lines (21 loc) · 822 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include "module.h"
#include <ctranslate2/scoring.h>
#include "utils.h"
namespace ctranslate2 {
namespace python {
void register_scoring_result(py::module& m) {
py::class_<ScoringResult>(m, "ScoringResult", "A scoring result.")
.def_readonly("tokens", &ScoringResult::tokens,
"The scored tokens.")
.def_readonly("log_probs", &ScoringResult::tokens_score,
"Log probability of each token")
.def("__repr__", [](const ScoringResult& result) {
return "ScoringResult(tokens=" + std::string(py::repr(py::cast(result.tokens)))
+ ", log_probs=" + std::string(py::repr(py::cast(result.tokens_score)))
+ ")";
})
;
declare_async_wrapper<ScoringResult>(m, "AsyncScoringResult");
}
}
}