-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathbert.h
More file actions
28 lines (21 loc) · 659 Bytes
/
bert.h
File metadata and controls
28 lines (21 loc) · 659 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
#ifndef BERT_H
#define BERT_H
#include "VoxCommon.hpp"
#include "berttokenizer.h"
// BERT: Class for inference of TorchScript-exported BERT.
class BERT
{
private:
torch::jit::script::Module Model;
std::unique_ptr<FullTokenizer> Tokenizer;
public:
BERT();
BERT(const std::string& Path,const std::string& DictPath);
void Initialize(const std::string& Path,const std::string& DictPath);
// Do inference on BERT model.
// Returns 2 tensors:
// [1, tokens, channels] : Hidden states
// [1, channels] : Pooled embeddings
std::pair<TFTensor<float>,TFTensor<float>> Infer(const std::string& InText);
};
#endif // BERT_H