Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Training without subwords #29

Closed
sebpuetz opened this issue Apr 5, 2019 · 2 comments
Closed

Training without subwords #29

sebpuetz opened this issue Apr 5, 2019 · 2 comments
Labels
feature New feature or request
Milestone

Comments

@sebpuetz
Copy link
Member

sebpuetz commented Apr 5, 2019

#13 was a first stab at it, maybe we can include this in 0.6?

@sebpuetz sebpuetz added the feature New feature or request label Apr 5, 2019
@sebpuetz sebpuetz added this to the release-0.6 milestone Apr 5, 2019
@sebpuetz sebpuetz mentioned this issue Jun 7, 2019
@danieldk
Copy link
Member

See #46 and #47 .

I still don't like the data structures in either PR. I feel like they do not really clearly convey the semantics. I don't have a perfect solution yet. One rough idea is to have a single struct:

struct WordIndex<S>
where
    S: AsRef<[usize]>,
{
    word_idx: usize,
    subword_indices: S,
}

impl WordIndex<[usize; 0]> {
    fn new(word_idx: usize) -> Self {
        WordIndex {
            word_idx,
            subword_indices: Default::default(),
        }
    }
}

impl WordIndex<Vec<usize>> {
    fn new_with_subwords(word_idx: usize, subword_indices: impl Into<Vec<usize>>) -> Self {
        WordIndex {
            word_idx,
            subword_indices: subword_indices.into(),
        }
    }
}

impl<S> WordIndex<S>
where
    S: AsRef<[usize]>,
{
    fn word_index(&self) -> usize {
        *self.word_index
    }

    fn subwords_indices(&self) -> &[usize] {
        self.subword_indices.as_ref()
    }
}

Then the rest of finalfrontier can be oblivious to subwords.

@sebpuetz
Copy link
Member Author

Merged in #54

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Development

No branches or pull requests

2 participants