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

add document for GenAI #7170

Merged
merged 1 commit into from
Jun 13, 2024

Conversation

LittleLittleCloud
Copy link
Contributor

@LittleLittleCloud LittleLittleCloud commented Jun 6, 2024

We are excited to review your PR.

So we can do the best job, please check:

  • There's a descriptive title that will make sense to other developers some time from now.
  • There's associated issues. All PR's should have issue(s) associated - unless a trivial self-evident change such as fixing a typo. You can use the format Fixes #nnnn in your description to cause GitHub to automatically close the issue(s) when your PR is merged.
  • Your change description explains what the change does, why you chose your approach, and anything else that reviewers should know.
  • You have included any necessary tests in the same PR.
  • [ ]
    Add desgin document for Add GenAI packages #7169

@luisquintanilla
Copy link
Contributor

luisquintanilla commented Jun 11, 2024

@NiklasGustafsson @stephentoub @SteveSandersonMS can you please take a look and provide feedback.

This is the design document for the GenAI library which consolidates the models ported to TorchSharp (Phi, Llama, StableDiffusion) into a single library for easier consumption.

{
public virtual (
Tensor, // output token ids [batch_size, sequence_length]
Tensor // output logits [batch_size, sequence_length, vocab_size]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the TorchSharp tensor type? Can / should it become the System.Numerics.Tensors one?

Copy link
Contributor Author

@LittleLittleCloud LittleLittleCloud Jun 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the TorchSharp tensor type

Yes

should it become the System.Numerics.Tensors one?

If System.Numerics.Tensors can work with libtorch, then maybe yes.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're some ways from having Tensor integrated with TorchSharp, it is still experimental and subject to change.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And it would be the TorchSharp shim implementing ITensor, not Tensor from SNT.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Presumably it would be ITensor<T> such that a Tensor<T> could be passed in? The implementation could type test if it were a TorchSharp implementation and act accordingly, presumably.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, in the fullness of time.

where TTokenizer : ITokenizer
where TCausalLM : nn.Module<CausalLanguageModelInput, CausalLanguageModelOutput>
{
public CausalLMPipeline<LLama2Tokenizer, Phi3ForCasualLM> Create(LLama2Tokenizer tokenizer, Phi3ForCasualLM model);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Presumably this is intended to instead be a static method on the base class?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm on the second thought, maybe not. Because CasualLMPipeline and CasualLMPipeline<TTokenizer, TCasualLM> will live in GenAI.Core while Phi3ForCasualLM lives in GenAI.Phi3.

In that case, this Create method is no longer necessary exist, using a constructor to take TTokenzier and TCausalLM would be easier to understand

Copy link
Contributor

@luisquintanilla luisquintanilla left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@LittleLittleCloud LittleLittleCloud merged commit 83b4f18 into dotnet:main Jun 13, 2024
4 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Jul 14, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants