AI大模型千问 qwen 中文文档AutoTokenizer device = "cuda" # the device to load the model onto # Now you do not need to add "trust_remote_code=True" model = AutoModelForCausalLM.from_pretrained( "Qwen/Qwen1.5-7B-Chat", torch_dtype="auto", device_map="auto" AutoTokenizer 借助 TextStreamer ,chat 的流式模式变得非常简单。下面我们将展示一个如何使用它的示例: ... # Reuse the code before `model.generate()` in the last code snippet from transformers import TextStreamer streamer = TextStreamer(tokenizer AutoTokenizer device = "cuda" # the device to load the model onto # Now you do not need to add "trust_remote_code=True" model = AutoModelForCausalLM.from_pretrained( "Qwen/Qwen1.5-7B-Chat", torch_dtype="auto", device_map="auto"0 码力 | 56 页 | 835.78 KB | 1 年前3
《Efficient Deep Learning Book》[EDL] Chapter 2 - Compression Techniqueslearning follow right after. The quantization section delves into the implementation details using code samples. We finish with a hands-on project that will walk you through the process of applying quantization contains the symbol-code mapping is transmitted along with the encoded data. Figure 2-1: Huffman Encoding & Huffman Tree. Source When decoding the encoded data, we look up the code from the lookup table back. Since the codes are unique for each symbol (in fact, they are prefix codes: no code is a prefix of some other code, which eliminates ambiguity when decoding), we can easily construct the original sequence0 码力 | 33 页 | 1.96 MB | 1 年前3
《Efficient Deep Learning Book》[EDL] Chapter 3 - Learning TechniquesEnglish to Spanish translation model. Let’s dig deeper into each of these categories using examples and code samples. Label Invariant Transformations Label invariant transformations transform samples such These values are clipped to 255. We will discuss some examples of image transformations below. The code samples are provided to bridge the theory and practice gap. We have prepared a few helper functions: image_path = 'file:///whalefin.png' Now, let’s go through the various image transformations with code examples. Rotation rotates the image pixels around the center. It is parameterized by . A positive0 码力 | 56 页 | 18.93 MB | 1 年前3
PyTorch Tutorial/Miniconda3-latest-Linux-x86_64.sh • After Miniconda is installed: conda install pytorch -c pytorch Writing code • Up to you; feel free to use emacs, vim, PyCharm, etc. if you want. • Our recommendations: • Install: 1234:localhost:1234 __@__.cs.princeton.edu • First blank is username, second is hostname Jupyter Notebook VS Code • Install the Python extension. • ???????????? Install the Remote Development extension. • Python Jupyter notebooks by delimiting cells/sections with #%% • Debugging PyTorch code is just like debugging any other Python code: see Piazza @108 for info. Also try Jupyter Lab! Why talk about libraries0 码力 | 38 页 | 4.09 MB | 1 年前3
keras tutorial Core Layers Convolution Layers Pooling Layers Recurrent Layers A simple python code to represent a neural network model using sequential model is as follows: from keras.models import your root directory under .keras/keras.json file. Keras backend module can be imported using below code: >>> from keras import backend as k If we are using default backend TensorFlow, then the below call and compute_output_shape completes the creating a customized layer. The final and complete code is as follows: from keras import backend as K from keras.layers import Layer Keras0 码力 | 98 页 | 1.57 MB | 1 年前3
PyTorch Brand Guidelinessocial media posts, please reference the digital RGB or hex code equivalent. When printing, please use CMYK or the listed Pantone code. For UI button elements, please reference “Color Variations communications. When using digitally, please use the hex code or RGB equivalent. When printing, please use CMYK or the listed Pantone code. 9 Brand Guidelines PyTorch Indigo (Digital+Print) social media posts, please reference the digital RGB or hex code equivalent. When printing, please use CMYK or the listed Pantone code. 9 Brand Guidelines PyTorch Super Light Gray (Digital+Print)0 码力 | 12 页 | 34.16 MB | 1 年前3
《Efficient Deep Learning Book》[EDL] Chapter 5 - Advanced Compression Techniquesrequired libraries to start with. We will use the gzip python module for demonstrating compression. The code for this exercise is available as a Jupyter notebook here. %%capture import gzip import operator same number of weights pruned. Phew! It feels like we have gone through a lot of talk without much code! In chapter four, we trained a model to predict masks for pets to build snapchat like filters. Let’s prunable block using magnitude-based pruning. Note that the below code is in addition to the original segmentation project in chapter four. The code for this project is available as a Jupyter notebook here.0 码力 | 34 页 | 3.18 MB | 1 年前3
《Efficient Deep Learning Book》[EDL] Chapter 4 - Efficient Architectures[['efficient deep learning x123!']]).numpy()[0, :4] edl_sequence_output array([ 1, 1379, 1585, 1]) The code snippet above returns indices into the vocabulary we created in the previous step. Let's look up the TFHub14. These embeddings use a 250 dimensional vector to represent a token in the vocabulary. The below code snippet transforms the vocab tokens to their corresponding embeddings. import tensorflow_hub as tfhub word2vec_embeddings tensor should be (vocab_size, embedding_dim), i.e., (5000, 250). The following code snippet will verify that. embedding_dim = 250 # The shape of the word2vec_embeddings would be (vocabulary_size0 码力 | 53 页 | 3.92 MB | 1 年前3
PyTorch Release Notesarchitectures and an automatic mixed precision-like API that can be used seamlessly with your PyTorch code. ‣ A preview of Torch-TensorRT (1.4.0dev0) is now included. Torch-TRT is the TensorRT integration architectures and an automatic mixed precision-like API that can be used seamlessly with your PyTorch code. PyTorch Release 23.06 PyTorch RN-08516-001_v23.07 | 15 ‣ A preview of Torch-TensorRT (1.4 architectures and an automatic mixed precision-like API that can be used seamlessly with your PyTorch code. ‣ NVIDIA Deep Learning Profiler (DLProf) v1.8, which was included in the 21.12 container, was the0 码力 | 365 页 | 2.94 MB | 1 年前3
《Efficient Deep Learning Book》[EDL] Chapter 6 - Advanced Learning Techniques - Technical Reviewdeployment of such models is the GitHub’s Copilot software9 where GPT-3 is used for auto-completing code snippets with an IDE. End-users can also use GPT-3 API10 to build their own applications. Given the Project: Using Pre-trained Language Models for News Classification That was a lot of talk without any code. Our overarching goal with self-supervised learning is to be more efficient in the number of labels demonstrate better quality and faster convergence than a BERT model that is trained from scratch. The code for this project is available here as a Jupyter notebook. We will not be explicitly demonstrating0 码力 | 31 页 | 4.03 MB | 1 年前3
共 16 条
- 1
- 2













