input.go 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package input
  2. // Input represents one token in the input stream
  3. type Input struct {
  4. // Token is a single element of text.
  5. Token int32
  6. // Multimodal is opaque data representing a non-text
  7. // element such as an image (or part of one if the image
  8. // can be processed in pieces). It may be either together
  9. // with Token or on its own.
  10. Multimodal any
  11. // MultimodalHash is a unique representation of the data
  12. // stored in Multimodal, used for caching and comparing
  13. // equality.
  14. MultimodalHash uint64
  15. // SameBatch forces the following number of tokens to be processed
  16. // in a single batch, breaking and extending batches as needed.
  17. // Useful for things like images that must be processed in one
  18. // shot.
  19. SameBatch int
  20. }
  21. // MultimodalIndex is a multimodal element (such as an image)
  22. // together with an index into the slice of Inputs with the
  23. // corresponding token. Note that the index is not the same
  24. // as the position - to find that use the index with the
  25. // Positions slice.
  26. type MultimodalIndex struct {
  27. Index int
  28. Multimodal any
  29. }
  30. // Options contains the inputs for a model forward pass
  31. type Options struct {
  32. Inputs []int32
  33. Multimodal []MultimodalIndex
  34. Positions []int32
  35. Sequences []int
  36. Outputs []int32
  37. }