rvk7895 commited on
Commit
507df33
1 Parent(s): ec3ad5a
README.md CHANGED
@@ -1,218 +1,201 @@
1
  ---
2
- license: apache-2.0
3
- language:
4
- - en
5
- metrics:
6
- - accuracy
7
- tags:
8
- - document
9
- - code
10
- - code2doc
11
- - instruction_tuned
12
- - basemodel
13
- - pytorch
14
- - docstring
15
- - python
16
- - documentation
17
- - text-generation-inference
18
  library_name: transformers
19
- pipeline_tag: text-generation
20
- widget:
21
- - text: "<code>def get_np_array_transition_probability_matrix(int_num_states, np_array_A_matrix):print(np_array_A_matrix)np_array_A_matrix += (np.full((int_num_states, int_num_states), float_eps) - (np.identity(int_num_states) * float_eps))print(np_array_A_matrix)np_array_D_matrix = np.diag(np.sum(np_array_A_matrix, axis=1))print(np_array_D_matrix)np_array_D_matrix_inv = np.linalg.inv(np_array_D_matrix)print(np_array_D_matrix_inv)np_array_P_matrix = np.dot(np_array_D_matrix_inv, np_array_A_matrix)print(np_array_P_matrix)print(np.sum(np_array_P_matrix, axis=1))return np_array_P_matrix</code><question>Document the python code above.</question><doc>"
22
- example_title: "example"
23
-
24
  ---
25
- # pip-code-to-doc
26
 
27
- [pipableAi](https://www.linkedin.com/company/pipable.ai/about/)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
 
29
- [colab_notebook](https://colab.research.google.com/drive/17PyMU_3QN9LROy7x-jmaema0cuLRzBvc?usp=sharing)
30
 
31
- ## What have we built?
32
- A 1.3 bn code documentation model that outperforms most models on documenting codes and making your in-house libs ready for LLM and RAG pipelines.
33
- We have also open sourced a [parsing lib](https://github.com/PipableAI/pip-library-parser) for the same, together the lib and model can turn your codebase to functional parse tree ready to be consumed by LLMs to execute complex tasks.
34
- This is a further trained version of pip-sql-1.3b.
35
 
 
36
 
 
37
 
38
- ## How we built it?
39
 
40
- We used softmax cross entropy and a modified form of policy grad along with Q loss, optimized in an EM set up.
41
- Loss behaviour in the set up mentioned above -
42
 
 
43
 
44
- ## License
45
- The model is open source under apache 2.0. License
46
 
47
- ## Usage
48
-
49
-
50
- ### Library use
51
- ```python
52
- !pip3 install git+https://github.com/PipableAI/pip-library-parser
53
- !pip3 install atlassian-python-api
54
-
55
-
56
- from pip_library_parser import CodeToDocGenerator
57
- from atlassian import Jira
58
-
59
- import torch
60
- torch.set_default_device("cuda")
61
-
62
- # Instantiate the CodeToDocGenerator
63
- generator = CodeToDocGenerator()
64
-
65
- # Generate docstrings for the module's functions and methods
66
- module = Jira
67
- module_name = "atlassian.Jira"
68
-
69
- docs = generator.generate_module_docs(module, module_name)
70
- print(docs)
71
- ```
72
-
73
- ```python
74
- from pip_library_parser import CodeToDocGenerator
75
-
76
- # Instantiate the CodeToDocGenerator
77
- generator = CodeToDocGenerator()
78
-
79
- code_snippet = """
80
- def example_function(x):
81
- return x * 2
82
- """
83
-
84
- docstring = generator.generate_docstring_from_pip_model(code_snippet)
85
- print("Generated Docstring:")
86
- print(docstring)
87
- ```
88
-
89
- ### Installation
90
-
91
- ```bash
92
- pip install transformers
93
- ```
94
-
95
- ### Prompt
96
- ```python
97
- prompt = f"""<function_code>{code}</function_code>
98
- <question>Give one line description of the python code above in natural language.</question>
99
- <doc>"""
100
- ```
101
-
102
- ### PyTorch
103
- ```python
104
- from transformers import AutoModelForCausalLM, AutoTokenizer
105
- device = "cuda"
106
- model = AutoModelForCausalLM.from_pretrained("PipableAI/pip-code-to-doc-1.3b").to(device)
107
- tokenizer = AutoTokenizer.from_pretrained("PipableAI/pip-code-to-doc-1.3b")
108
- prompt = f"""
109
- <function_code>
110
- def example_function(x):
111
- return x * 2
112
- </function_code>
113
- <question>Give one line description of the python code above in natural language.</question>
114
- <doc>"""
115
- inputs = tokenizer(prompt, return_tensors="pt")
116
- outputs = model.generate(**inputs, max_new_tokens=300)
117
- tokenizer.decode(outputs[0], skip_special_tokens=True).split('<doc>')[-1].split('</doc>')[0]
118
- ```
119
-
120
-
121
-
122
- ## Examples
123
-
124
- ### prompt
125
- ```python
126
- <function_code>
127
- ###########################
128
- # Generate Analytical Model
129
- ###########################
130
- ##################################################
131
- # func: get_np_array_transition_probability_matrix
132
- ##################################################
133
- def get_np_array_transition_probability_matrix(int_num_states, np_array_A_matrix):
134
- print('np_array_A_matrix:')
135
- print(np_array_A_matrix)
136
- #####################################################
137
- # Perturb the adjacency matrix to avoid singularities
138
- #####################################################
139
- np_array_A_matrix += (np.full((int_num_states, int_num_states), float_eps) - (np.identity(int_num_states) * float_eps))
140
- print('np_array_A_matrix:')
141
- print(np_array_A_matrix)
142
- print('np_array_D_matrix:')
143
- np_array_D_matrix = np.diag(np.sum(np_array_A_matrix, axis=1))
144
- print(np_array_D_matrix)
145
- print('np_array_D_matrix_inv:')
146
- np_array_D_matrix_inv = np.linalg.inv(np_array_D_matrix)
147
- print(np_array_D_matrix_inv)
148
- print('\n\n')
149
- print('np_array_P_matrix:')
150
- np_array_P_matrix = np.dot(np_array_D_matrix_inv, np_array_A_matrix)
151
- print(np_array_P_matrix)
152
- print('np.sum(np_array_P_matrix, axis=1):')
153
- print(np.sum(np_array_P_matrix, axis=1))
154
- print('\n\n')
155
- return np_array_P_matrix
156
- ##################################################
157
- # func: get_np_array_perron_frobenius_eigen_vector
158
- ##################################################
159
- def get_np_array_perron_frobenius_matrix(int_num_states, np_array_P_matrix):
160
- np_array_perron_frobenius_matrix = np.linalg.matrix_power(np_array_P_matrix,1000)
161
- np_array_perron_frobenius_vector = np_array_perron_frobenius_matrix[0,:]
162
- print('np_array_perron_frobenius_matrix:')
163
- print(np_array_perron_frobenius_matrix)
164
- print('np.sum(np_array_perron_frobenius_matrix, axis=1):')
165
- print(np.sum(np_array_perron_frobenius_matrix, axis=1))
166
- print('np.sum(np_array_perron_frobenius_matrix, axis=0):')
167
- print(np.sum(np_array_perron_frobenius_matrix, axis=0))
168
- print('np.sum(np_array_perron_frobenius_matrix, axis=0)/int_num_states:')
169
- print(np.sum(np_array_perron_frobenius_matrix, axis=0)/int_num_states)
170
- print('np.dot(np_array_perron_frobenius_vector, np_array_P_matrix):')
171
- print(np.dot(np_array_perron_frobenius_vector, np_array_P_matrix))
172
- print('np_array_perron_frobenius_vector:')
173
- print(np_array_perron_frobenius_vector)
174
- print('\n\n')
175
- return np_array_perron_frobenius_vector, np_array_perron_frobenius_matrix
176
- #############################
177
- # func: get_np_array_Z_matrix
178
- #############################
179
- def get_np_array_Z_matrix(int_num_states, np_array_P_matrix, np_array_perron_frobenius_matrix):
180
- np_array_Z_matrix = np.linalg.inv(np.identity(int_num_states) - np_array_P_matrix + np_array_perron_frobenius_matrix)
181
- print('np_array_Z_matrix:')
182
- print(np_array_Z_matrix)
183
- print('\n\n')
184
- return(np_array_Z_matrix)
185
- #############################
186
- # func: get_np_array_H_matrix
187
- #############################
188
- def get_np_array_H_matrix(int_num_states, np_array_Z_matrix, np_array_perron_frobenius_vector):
189
- np_array_H_matrix = np.zeros([int_num_states, int_num_states])
190
- for i in range(int_num_states):
191
- for j in range(int_num_states):
192
- np_array_H_matrix[i][j] = (np_array_Z_matrix[j][j] - np_array_Z_matrix[i][j])/np_array_perron_frobenius_vector[j]
193
- print('np_array_H_matrix:')
194
- print(np_array_H_matrix)
195
- print('\n\n')
196
- return np_array_H_matrix
197
- ###########
198
- # func: run
199
- ###########
200
- def run(np_array_A_matrix):
201
- int_num_states = len(np_array_A_matrix)
202
- np_array_P_matrix = get_np_array_transition_probability_matrix(int_num_states, np_array_A_matrix)
203
- np_array_perron_frobenius_vector, np_array_perron_frobenius_matrix = get_np_array_perron_frobenius_matrix(int_num_states, np_array_P_matrix)
204
- np_array_Z_matrix = get_np_array_Z_matrix(int_num_states, np_array_P_matrix, np_array_perron_frobenius_matrix)
205
- np_array_H_matrix = get_np_array_H_matrix(int_num_states, np_array_Z_matrix, np_array_perron_frobenius_vector)
206
- return(np_array_H_matrix)
207
- </function_code>
208
- <question>Give one line description of the python code above in natural language.</question>
209
- <doc>
210
- ```
211
-
212
- ### Response
213
- ```txt
214
- The given python code is a function that calculates the transition probability matrix, P, for a given adjacency matrix A, and then uses these matrices to calculate the Perron-Frobenius eigenvector and its inverse matrix Z, and finally, the H matrix which is the inverse of the Z matrix. The H matrix is then returned as the output of the function. The adjacency matrix A is a square matrix where each element at position (i, j) represents the probability of transitioning from state i to state j. The function first perturbs the adjacency matrix to avoid singularities, then calculates the transition probability matrix P, the Perron-Frobenius eigenvector and its inverse matrix Z, and finally, the H matrix. The H matrix is then returned as the output of the function.
215
- ```
216
-
217
- ### Team
218
- Avi Kothari, Gyan Ranjan, Pratham Gupta, Ritvik Aryan Kalra, Soham Acharya
 
1
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  library_name: transformers
3
+ tags: []
 
 
 
 
4
  ---
 
5
 
6
+ # Model Card for Model ID
7
+
8
+ <!-- Provide a quick summary of what the model is/does. -->
9
+
10
+
11
+
12
+ ## Model Details
13
+
14
+ ### Model Description
15
+
16
+ <!-- Provide a longer summary of what this model is. -->
17
+
18
+ This is the model card of a 🤗 transformers model that has been pushed on the Hub. This model card has been automatically generated.
19
+
20
+ - **Developed by:** [More Information Needed]
21
+ - **Funded by [optional]:** [More Information Needed]
22
+ - **Shared by [optional]:** [More Information Needed]
23
+ - **Model type:** [More Information Needed]
24
+ - **Language(s) (NLP):** [More Information Needed]
25
+ - **License:** [More Information Needed]
26
+ - **Finetuned from model [optional]:** [More Information Needed]
27
+
28
+ ### Model Sources [optional]
29
+
30
+ <!-- Provide the basic links for the model. -->
31
+
32
+ - **Repository:** [More Information Needed]
33
+ - **Paper [optional]:** [More Information Needed]
34
+ - **Demo [optional]:** [More Information Needed]
35
+
36
+ ## Uses
37
+
38
+ <!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
39
+
40
+ ### Direct Use
41
+
42
+ <!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
43
+
44
+ [More Information Needed]
45
+
46
+ ### Downstream Use [optional]
47
+
48
+ <!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
49
+
50
+ [More Information Needed]
51
+
52
+ ### Out-of-Scope Use
53
+
54
+ <!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
55
+
56
+ [More Information Needed]
57
+
58
+ ## Bias, Risks, and Limitations
59
+
60
+ <!-- This section is meant to convey both technical and sociotechnical limitations. -->
61
+
62
+ [More Information Needed]
63
+
64
+ ### Recommendations
65
+
66
+ <!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
67
+
68
+ Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
69
+
70
+ ## How to Get Started with the Model
71
+
72
+ Use the code below to get started with the model.
73
+
74
+ [More Information Needed]
75
+
76
+ ## Training Details
77
+
78
+ ### Training Data
79
+
80
+ <!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
81
+
82
+ [More Information Needed]
83
+
84
+ ### Training Procedure
85
+
86
+ <!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
87
+
88
+ #### Preprocessing [optional]
89
+
90
+ [More Information Needed]
91
+
92
+
93
+ #### Training Hyperparameters
94
+
95
+ - **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
96
+
97
+ #### Speeds, Sizes, Times [optional]
98
+
99
+ <!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
100
+
101
+ [More Information Needed]
102
+
103
+ ## Evaluation
104
+
105
+ <!-- This section describes the evaluation protocols and provides the results. -->
106
+
107
+ ### Testing Data, Factors & Metrics
108
+
109
+ #### Testing Data
110
+
111
+ <!-- This should link to a Dataset Card if possible. -->
112
+
113
+ [More Information Needed]
114
+
115
+ #### Factors
116
+
117
+ <!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
118
+
119
+ [More Information Needed]
120
+
121
+ #### Metrics
122
+
123
+ <!-- These are the evaluation metrics being used, ideally with a description of why. -->
124
+
125
+ [More Information Needed]
126
+
127
+ ### Results
128
+
129
+ [More Information Needed]
130
+
131
+ #### Summary
132
+
133
+
134
+
135
+ ## Model Examination [optional]
136
+
137
+ <!-- Relevant interpretability work for the model goes here -->
138
+
139
+ [More Information Needed]
140
+
141
+ ## Environmental Impact
142
+
143
+ <!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
144
+
145
+ Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
146
+
147
+ - **Hardware Type:** [More Information Needed]
148
+ - **Hours used:** [More Information Needed]
149
+ - **Cloud Provider:** [More Information Needed]
150
+ - **Compute Region:** [More Information Needed]
151
+ - **Carbon Emitted:** [More Information Needed]
152
+
153
+ ## Technical Specifications [optional]
154
+
155
+ ### Model Architecture and Objective
156
+
157
+ [More Information Needed]
158
+
159
+ ### Compute Infrastructure
160
+
161
+ [More Information Needed]
162
+
163
+ #### Hardware
164
+
165
+ [More Information Needed]
166
+
167
+ #### Software
168
+
169
+ [More Information Needed]
170
+
171
+ ## Citation [optional]
172
+
173
+ <!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
174
+
175
+ **BibTeX:**
176
+
177
+ [More Information Needed]
178
+
179
+ **APA:**
180
+
181
+ [More Information Needed]
182
+
183
+ ## Glossary [optional]
184
+
185
+ <!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
186
 
187
+ [More Information Needed]
188
 
189
+ ## More Information [optional]
 
 
 
190
 
191
+ [More Information Needed]
192
 
193
+ ## Model Card Authors [optional]
194
 
195
+ [More Information Needed]
196
 
197
+ ## Model Card Contact
 
198
 
199
+ [More Information Needed]
200
 
 
 
201
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
model-00001-of-00002.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:697fbfcae2740a7b7964feae15c0bc5f699de0e80c962549840d49aef0b682e0
3
  size 4986380064
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:00a3309db09b06ad2df7eb879d3b6ef3df635a8a4591f62a03621972682f95ef
3
  size 4986380064
model-00002-of-00002.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:7db6ad5468af3edbd27d05a5d8e4ec405c33c4997a2767932c34ee73f8f64f6e
3
  size 399532808
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c3bde8d98d16a8d6e5a9bdbe1a94e00f848265b419bf04a98d34f7a8fc0d11b0
3
  size 399532808
pytorch_model.bin CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:ead7b223fe28322d216004963087f39100988fe08b3b2290cfa18b09290bf2c1
3
  size 5385980246
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e4398df56a5a218c969e711605e433d374526a114d1d563bccbe118c94984511
3
  size 5385980246