pulsatrix
Loading...
Searching...
No Matches
text_dataset.hpp
Go to the documentation of this file.
1
5#pragma once
6
7#include <string>
8#include <vector>
9
10#include "pulsatrix/dataset.hpp"
13
14namespace pulsatrix {
15
25class TextDataset : public Dataset {
26public:
35 TextDataset(const std::string& corpus_path, const Vocabulary* vocabulary, DeviceBackend* backend);
36
37 [[nodiscard]] int64_t size() const override;
38
40 [[nodiscard]] Sample get(int64_t index) const override;
41
42private:
43 std::vector<std::string> lines_;
44 const Vocabulary* vocabulary_;
45 DeviceBackend* backend_;
46};
47
48} // namespace pulsatrix
Random-access dataset abstraction – pulsatrix's analogue of PyTorch's torch.utils....
Definition dataset.hpp:33
Vendor-agnostic compute/memory backend. CPUBackend, CUDABackend (Phase 1.5), and HIPBackend (Phase 1....
Definition device_backend.hpp:219
Dataset over a line-delimited text corpus: each line becomes one sample, tokenized via Tokenizer::Tok...
Definition text_dataset.hpp:25
int64_t size() const override
Number of samples in this dataset.
TextDataset(const std::string &corpus_path, const Vocabulary *vocabulary, DeviceBackend *backend)
Sample get(int64_t index) const override
Token<->index lookup table. Index 0 is always the reserved "<unk>" token – guaranteed by construction...
Definition vocabulary.hpp:19
Random-access dataset abstraction – Sample, Dataset (size()/get()).
Abstract interface isolating vendor-specific memory/compute operations from Tensor/ComputationGraph.
Definition acquisition_functions.hpp:16
One dataset sample: an ordered list of Tensor fields (e.g. {features, label} or {image,...
Definition dataset.hpp:19
Token<->index lookup with a reserved <unk> fallback, plus a frequency-ranked builder.