You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

07_emb_sp.ipynb 2.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. {
  2. "cells": [
  3. {
  4. "cell_type": "code",
  5. "execution_count": 1,
  6. "id": "4c6f353f-83e2-4780-9124-bf7f30e2a77d",
  7. "metadata": {
  8. "tags": []
  9. },
  10. "outputs": [],
  11. "source": [
  12. "from typing import Optional\n",
  13. "\n",
  14. "import numpy as np\n",
  15. "from tqdm import tqdm\n",
  16. "\n",
  17. "import wandb\n",
  18. "import torch\n",
  19. "import torch.nn as nn\n",
  20. "from transformers import T5TokenizerFast, T5ForConditionalGeneration\n",
  21. "\n",
  22. "from _config import load_config\n",
  23. "from _utils import print_system_info, silent_logs\n",
  24. "from _datasets import AutoLoad, generate_dataloader\n",
  25. "from _mydelta import T5Wrapper, auto_freeze, EmbeddingWrapper\n",
  26. "from _trainer import train_loop, valid_loop, BestFinder\n",
  27. "\n",
  28. "# configs = load_config('./config.yaml')\n",
  29. "\n",
  30. "# RANDOM_SEED = configs.shared.random_seed\n",
  31. "# WANDB_PROJECT_NAME = configs.shared.project_name\n",
  32. "# DEVICE = torch.device(\"cuda:0\" if torch.cuda.is_available() else \"cpu\")\n",
  33. "# USE_TQDM = configs.shared.use_tqdm\n",
  34. "\n"
  35. ]
  36. },
  37. {
  38. "cell_type": "code",
  39. "execution_count": 2,
  40. "id": "ead0c663-c9e4-4625-8f3b-11e53ca59920",
  41. "metadata": {},
  42. "outputs": [],
  43. "source": [
  44. "model = T5ForConditionalGeneration.from_pretrained('google/t5-large-lm-adapt')\n",
  45. "tokenizer = T5TokenizerFast.from_pretrained('google/t5-large-lm-adapt', model_max_length=2048)"
  46. ]
  47. },
  48. {
  49. "cell_type": "code",
  50. "execution_count": null,
  51. "id": "e348f601-c713-49af-86e4-a40382c5a36f",
  52. "metadata": {},
  53. "outputs": [],
  54. "source": [
  55. "num_tokens = 100"
  56. ]
  57. },
  58. {
  59. "cell_type": "code",
  60. "execution_count": null,
  61. "id": "6d9a6602-f90d-440a-b11e-ddda2d36d2f7",
  62. "metadata": {},
  63. "outputs": [],
  64. "source": []
  65. }
  66. ],
  67. "metadata": {
  68. "kernelspec": {
  69. "display_name": "Python [conda env:deep]",
  70. "language": "python",
  71. "name": "conda-env-deep-py"
  72. },
  73. "language_info": {
  74. "codemirror_mode": {
  75. "name": "ipython",
  76. "version": 3
  77. },
  78. "file_extension": ".py",
  79. "mimetype": "text/x-python",
  80. "name": "python",
  81. "nbconvert_exporter": "python",
  82. "pygments_lexer": "ipython3",
  83. "version": "3.10.11"
  84. }
  85. },
  86. "nbformat": 4,
  87. "nbformat_minor": 5
  88. }